Working with json using EvaluateJsonPath in Apache Nifi
A) Fetch json array from json object using EvaluateJsonPath in Apache Nifi
For a given json find phoneNumbers json array
{
"firstName": "John",
"lastName" : "doe",
"age" : 26,
"address" : {
"streetAddress": "naist street",
"city" : "Nara",
"postalCode" : "630-0192"
},
"phoneNumbers": [
{
"type" : "iPhone",
"number": "0123-4567-8888"
},
{
"type" : "home",
"number": "0123-4567-8910"
}
]
}
Then use below
$.phoneNumbers[:]
Result
[
{
"type": "iPhone",
"number": "0123-4567-8888"
},
{
"type": "home",
"number": "0123-4567-8910"
}
]
B) For given json find first object from array and get its “type” from the object
[
{
"type": "iPhone",
"number": "0123-4567-8888"
},
{
"type": "home",
"number": "0123-4567-8910"
}
]
Fetch first json and the type of it
$[0].type
Online json query tool is a great help
Comments
Post a Comment