Skip to content
Advertisement

How to extract the field from JSON object with QueryRecord

I have been struggling with this problem for a long time. I need to create a new JSON flowfile using QueryRecord by taking an array (field ref) from input JSON field refs and skip the object field as shown in example below:

Input JSON flowfile

QueryRecord configuration

JSONTreeReader setup as Infer Schema and JSONRecordSetWriter

Output JSON (need)

But got error: QueryRecord Failed to write MapRecord[{references=[Ljava.lang.Object;@27fd935f, description=full1, name=name1}] with schema ["name" : "STRING", "description" : "STRING", "references" : "ARRAY[STRING]"] as a JSON Object due to java.lang.ClassCastException: null

Advertisement

Answer

Solution!: use JoltTransformJSON to transform JSON by Jolt specification. About this specification.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement