Skip to content

NIFI-15712 Add JSON Lines support to JoltTransformJSON#11001

Merged
pvillard31 merged 2 commits intoapache:mainfrom
exceptionfactory:NIFI-15712
Mar 13, 2026
Merged

NIFI-15712 Add JSON Lines support to JoltTransformJSON#11001
pvillard31 merged 2 commits intoapache:mainfrom
exceptionfactory:NIFI-15712

Conversation

@exceptionfactory
Copy link
Contributor

@exceptionfactory exceptionfactory commented Mar 13, 2026

Summary

NIFI-15712 Adds support for JSON Lines to the JoltTransformJSON Processor as a new option for the JSON Source property.

Support for JSON Lines enables JoltTransformJSON to process multiple JSON elements in a single FlowFile, reading, transforming, and writing each element with a newline delimiter.

Although the JoltTransformRecord Processor supports similar handling with a configured JSON Record Reader and JSON Record Writer, record-oriented handling requires configured a Record Schema strategy. Supporting JSON Lines in JoltTransformJSON supports widely varying JSON elements in a single FlowFile and avoids the need to specify or infer a Record Schema.

Support for JSON Lines includes some restructuring for better code reuse in JoltTransformJSON, along with new unit tests to verify expected behavior.

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

@exceptionfactory exceptionfactory changed the title NIFI-15217 Add JSON Lines support to JoltTransformJSON NIFI-15712 Add JSON Lines support to JoltTransformJSON Mar 13, 2026
final Object inputJson = jsonUtil.jsonToObject(line);
final Object transformedJson = TransformUtils.transform(transform, inputJson);
writer.write(jsonUtil.toJsonString(transformedJson));
writer.newLine();
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that in this case we need to use

Suggested change
writer.newLine();
writer.write('\n');

The JSON Lines specification mandates \n (0x0A) as the line separator. BufferedWriter.newLine() uses System.lineSeparator(), which is \r\n on Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, although both should work in general, the single character is correct, I will push a correction.

Copy link
Contributor

@pvillard31 pvillard31 left a comment

Choose a reason for hiding this comment

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

Thanks @exceptionfactory , LGTM, merging

@pvillard31 pvillard31 merged commit 52b9398 into apache:main Mar 13, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants