How to access the nested fields in a json using expression language in Nifi?
Hi,
I have an input json as below:
[
{
"orderId": "1234567890",
"orderName": "Test1",
"orderItems": [
{
"orderItemId": "01",
"orderItemName": "test1-OrderItem1"
},
{
"orderItemId": "02",
"orderItemName": "test1-OrderItem2"
}
]
},
{
"orderId": "12235",
"orderName": "Test2",
"orderItems": [
{
"orderItemId": "01",
"orderItemName": "test2-OrderItem1"
}
]
},
{
"orderId": "12236",
"orderName": "Test3",
"orderItems": [
{
"orderItemId": "01",
"orderItemName": "test3-OrderItem1"
}
]
}
]
I want to convert it into text form where we want the order details and then item details for each map in the list.
Here is the desired output:
1234567890 Test1
01 test1-OrderItem1
02 test1-OrderItem2
12235 Test2
01 test2-OrderItem1
12236 Test3
01 test3-OrderItem1
This is json to csv conversion, and I am using the ConvertRecord processor and below are the reader and writer configured:
1. Record Reader - JsonTreeReader
2. Record Writer - FreeFormTextRecordSetWriter
For the FreeFormTextRecordSetWriter controller service in the text property, I added the key names from the input json like this ${keyName} and got the values but in the next line, I wanted orderItemId from all the maps in the orderItems list.
How can I access the values from orderItems list?
Thanks in advance!

