- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How can I write EcmaScript for this case.
- Labels:
-
Apache NiFi
Created ‎05-03-2023 07:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have this data saved in an attribute lets say "Data" .I have to Match this "Your_Name" present in this Data with some Field(mentioned below) which will be called after API.
[
{
"admin": "A1",
"Your_Name": "Lily",
"Reason1": "Shot"
}
]
Now, This is the data which will get after API call in InvokeHttp processor, I have stored it in an "ResponseData" attribute using ExtractText.
I have to match Data's "Your_Name" with ResponseData's "Name", if both of these matches we will send the respectives "nameId" in some outputstream variable or something so that it can go ahead as an output(the nameId only of the Name which matched with Your_Name).
[ {
"Name" : "Ivor",
"Speciality" : [ {
"nameId" : "611",
"SId" : "2"
} ]
}, {
"Name" : "Philip",
"Speciality" : [ {
"nameId" : "980",
"SId" : "12"
} ]
}, {
"Name" : "Adams",
"Speciality" : [ {
"nameId" : "611",
"SId" : "2"
} ]
},
{
"Name" : "Lily",
"Speciality" : [ {
"nameId" : "618",
"SId" : "20"
} ]
}
]
Two of the Name (here Ivor and Adams) can have the same nameID, So we have to match Name and send its nameId only. I want to write ECMA script for this.
Created ‎05-04-2023 05:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@anony I believe your solution is to put/keep Response Data as flowfile content. Then you can do QueryRecord or PartitionRecord to iterate through each "name" object in the Response Data array. Then downstream you are able to use EvalateJsonPath to get the json object values into attributes or flowfile content. For example name= $.name, nameID = $.Speciality[0].nameId, etc
Created ‎06-14-2023 03:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does it need to be ECMA? I can probably whip something up tomorrow using Groovy.
