The Beast
The Beast

Reputation: 133

Nifi - edit json flow file content

I am using Nifi 1.6.0. I am trying to copy an S3 file into redshift. The json file on S3 looks like this:

[
  {
    "a": 1,
    "b": 2
  },
  {
    "a": 3,
    "b": 4
  }
]

However this gives an error (Invalid JSONPath format: Member is not an object.) because of '[' and ']' in the file (https://stackoverflow.com/a/45348425).

I need to convert the json from above format to a format which looks like this:

{
  "a": 1,
  "b": 2
}
{
  "a": 3,
  "b": 4
}

So basically what I am trying to do is to remove '[' and ']' and replace '},\n' with '}\n'.

The file has over 14 million rows (113 MB in size)

How can I achieve this using Nifi?

Upvotes: 0

Views: 427

Answers (1)

yaprak
yaprak

Reputation: 547

You can use ReplaceText. Check this. It is very similar to your problem. First replace brackets with empty string then replace commas by using LiteralReplace strategy

Upvotes: 1

Related Questions