6

Is there a processor / flow I am not considering when wanting to convert JsonMessages merged together (using MergeContent) into a JsonArray? I wanted to try to build JsonArrays from Multiple files and then pass to the QueryRecord to run SQL. Good chance I am missing an out of the box/ obvious way to do that. Any help would be greatly appreciated.

I could use a groovy execute script, but was wanting to avoid custom code, if possible. Thanks!

Messages In -> MergeContent -> ConvertToJsonArray -> QueryRecord.

1 Answer 1

13

You can use MergeContent and set the Delimiter Strategy to "Text" and then enter [ , ] for the header, demarcator, and footer respectively.

That will insert the header at the beginning of the flow file, the demarcator between every flow file, and the footer at the end.

Alternatively, since it looks like you are using the record stuff, the latest release should have a MergeRecord processor which handle this for you if you used a JsonTreeReader and JsonRecordSetWriter.

3
  • awesome. Worked great. Thanks!
    – scarpacci
    Oct 27, 2017 at 17:06
  • What if I wanted to separate json by a new line? I typed \n in the demarcator but it prints a '\n'
    – 3nomis
    May 3, 2019 at 10:03
  • 1
    Use shift+enter to make a new line for the demarcator, or use MergeRecord and set the JsonRecordSetWriter to per-line May 3, 2019 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.