Skip to content

NIFI-15716 Added JSON Lines Support to ValidateJson.#11012

Open
dan-s1 wants to merge 6 commits intoapache:mainfrom
dan-s1:NIFI-15716
Open

NIFI-15716 Added JSON Lines Support to ValidateJson.#11012
dan-s1 wants to merge 6 commits intoapache:mainfrom
dan-s1:NIFI-15716

Conversation

@dan-s1
Copy link
Contributor

@dan-s1 dan-s1 commented Mar 16, 2026

Summary

NIFI-15716
The following PR introduces support for JSON Lines or NDJSON in the ValidateJson processor. The initial approach is to validate each object and fail fast on the first object which is invalid. The emitted warning message indicates which line has the invalid JSON object. I would like clarification if the line number should also be added to the FlowFile attribute json.validation.errors that is added to hold the validation error messages.
In addition to aforementioned feature, Intellij warnings were fixed and in one unit test the use of Jupitor Arguments.argumentSet replaced the use of Arguments.arguments

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000
  • Pull request contains commits signed with a registered key indicating Verified status

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using ./mvnw clean install -P contrib-check
    • JDK 21
    • JDK 25

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this support in ValidateJson @dan-s1. I think it would be helpful to include the line number in the FlowFile attribute, in answer to your question. I noted a handful of recommended adjustments.

@dan-s1 dan-s1 requested a review from exceptionfactory March 17, 2026 18:08
@dan-s1 dan-s1 force-pushed the NIFI-15716 branch 2 times, most recently from f907a6d to 62ef295 Compare March 24, 2026 18:51
Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dan-s1, I noted a few more minor recommendations.

Comment on lines +86 to +87
"This Processor supports input containing multiple JSON objects using newline-delimited JSON based on configuration properties, " +
"otherwise if the input FlowFile contains newline-delimited JSON, only the first line will be validated."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good opportunity to switch the value to a multi-line string.

}

protected static final String ERROR_ATTRIBUTE_KEY = "json.validation.errors";
public enum InputFormat implements DescribedValue {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public enum InputFormat implements DescribedValue {
enum InputFormat implements DescribedValue {

}
}

void validateSingleJson(ProcessSession session, FlowFile flowFile) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validateFlowFile seems like a better name given the Input Format value.

Suggested change
void validateSingleJson(ProcessSession session, FlowFile flowFile) {
void validateFlowFile(final ProcessSession session, final FlowFile flowFile) {

}
}

void validateJsonLines(ProcessSession session, FlowFile flowFile) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void validateJsonLines(ProcessSession session, FlowFile flowFile) {
void validateJsonLines(final ProcessSession session, final FlowFile flowFile) {

session.getProvenanceReporter().route(flowFile, REL_VALID);
session.transfer(flowFile, REL_VALID);

} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} catch (Exception e) {
} catch (final Exception e) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants