Arsalan,

If I understand your use case correctly, you could use SplitJson with
a JSONPath of "$.Records", this will emit one flow file for each entry
in the array. Then you could use ConvertJSONtoAvro (it should infer
the schema but you could either use InferAvroSchema or supply one if
you know it). At that point you'd have flow files each containing a
single Avro record corresponding to an entry in the JSON "Records"
array.

If you'd rather keep the records together, you could use
JoltTransformJSON [1] processor to remove "NrRecords", "FileRecords",
etc. or just keep "Records". Then you could use ConvertJSONtoAvro
which should give you a single Avro file with multiple entries inside.

Regards,
Matt

[1] 
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.JoltTransformJSON/index.html

On Wed, Oct 26, 2016 at 7:52 AM, Arsalan Siddiqi
<[email protected]> wrote:
> Hi I am not very familiar with Regexs. The following is the json format data
> being delivered to the replace text processor.
>
> {"NrRecords":1,"FileRecords":-1,"Records":[{"ISN":250,"AA":"11222222","AF":"S","AG":"F"}]}
>
> I want to replace this with
> [{"ISN":250,"AA":"11222222","AF":"S","AG":"F"}]
>
> and obviously the records can be more than one. I need to convert this JSON
> to avro so i would need to define the schema first. The infer schema would
> infer it based on the number of records that are retrieved. If they are more
> than one then it thinks that this entire file is one record and passing it
> through the "split avro" does not split it correctly (it does not split the
> file and the output is the same original file). The ideal case would be to
> get rid of this header in the file and then I think it will be able to
> process the records. I want to then split the file into seperate files equal
> to the number of records retrieved.
>
> I am not very familiar with regex, groups and back-references. I was
> wondering if there was a way to write a regex that extracts the value
> between the first [ and the last ] and assign it back to the flow file
> content.
>
> thanks
> Arsalan
>
>
>
> --
> View this message in context: 
> http://apache-nifi-developer-list.39713.n7.nabble.com/Replace-Text-for-updating-the-flow-file-content-tp13712.html
> Sent from the Apache NiFi Developer List mailing list archive at Nabble.com.

Reply via email to