Repository: nifi Updated Branches: refs/heads/master 5d3558a79 -> db645ec47
NIFI-3344 Added property to JoltTransformJSON allowing the user to specify pretty print, defaults to false Signed-off-by: Pierre Villard <[email protected]> This closes #2987. Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/db645ec4 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/db645ec4 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/db645ec4 Branch: refs/heads/master Commit: db645ec475416b77018fcae0d25e5b5dfd801b15 Parents: 5d3558a Author: Nick Lewis <[email protected]> Authored: Fri Aug 31 09:12:05 2018 -0500 Committer: Pierre Villard <[email protected]> Committed: Tue Sep 25 23:07:24 2018 +0200 ---------------------------------------------------------------------- .../nifi/processors/standard/JoltTransformJSON.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/db645ec4/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/JoltTransformJSON.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/JoltTransformJSON.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/JoltTransformJSON.java index 872535d..6a2b15a 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/JoltTransformJSON.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/JoltTransformJSON.java @@ -130,6 +130,15 @@ public class JoltTransformJSON extends AbstractProcessor { .required(true) .build(); + public static final PropertyDescriptor PRETTY_PRINT = new PropertyDescriptor.Builder() + .name("pretty_print") + .displayName("Pretty Print") + .description("Apply pretty print formatting to the output of the Jolt transform") + .required(true) + .allowableValues("true", "false") + .defaultValue("false") + .build(); + public static final Relationship REL_SUCCESS = new Relationship.Builder() .name("success") .description("The FlowFile with transformed content will be routed to this relationship") @@ -164,6 +173,7 @@ public class JoltTransformJSON extends AbstractProcessor { _properties.add(MODULES); _properties.add(JOLT_SPEC); _properties.add(TRANSFORM_CACHE_SIZE); + _properties.add(PRETTY_PRINT); properties = Collections.unmodifiableList(_properties); final Set<Relationship> _relationships = new HashSet<>(); @@ -275,7 +285,7 @@ public class JoltTransformJSON extends AbstractProcessor { } final Object transformedJson = TransformUtils.transform(transform,inputJson); - jsonString = JsonUtils.toJsonString(transformedJson); + jsonString = context.getProperty(PRETTY_PRINT).asBoolean() ? JsonUtils.toPrettyJsonString(transformedJson) : JsonUtils.toJsonString(transformedJson); } catch (final Exception ex) { logger.error("Unable to transform {} due to {}", new Object[] {original, ex.toString(), ex}); session.transfer(original, REL_FAILURE);
