Created 02-27-2023 05:51 AM
So I'm working with a batch JSON file with the following value :
[
{
"eventType": "UPDATE",
"eventTime": "2021-12-14T12:34:56.789012Z",
"country": "ES",
"resourceType": "Party"
},
{
"eventType": "UPDATE",
"eventTime": "2021-12-14T12:34:56.789012Z",
"country": "ES",
"resourceType": "Party"
},
{
"eventType": "UPDATE",
"eventTime": "2021-12-14T12:34:56.789012Z",
"country": "FR",
"resourceType": "Party"
},
{
"eventType": "UPDATE",
"eventTime": "2021-12-14T12:34:56.789012Z",
"country": "FR",
"resourceType": "Party"
}
]
So I'm working with a batch JSON file with the following value :
[
{
"eventType": "UPDATE",
"eventTime": "2021-12-14T12:34:56.789012Z",
"country": "ES",
"resourceType": "Party"
},
{
"eventType": "UPDATE",
"eventTime": "2021-12-14T12:34:56.789012Z",
"country": "ES",
"resourceType": "Party"
},
{
"eventType": "UPDATE",
"eventTime": "2021-12-14T12:34:56.789012Z",
"country": "FR",
"resourceType": "Party"
},
{
"eventType": "UPDATE",
"eventTime": "2021-12-14T12:34:56.789012Z",
"country": "FR",
"resourceType": "Party"
}
]
I'm able to extract attributes from JSON by using EvaluateJsonPath processor.
UpdateAttribute is the processor where i want to extract the attributes. Please find below snapshot of UpdateAttribute processor when value of "country="ES"
I want get json file like this:
[
{
"eventType": "UPDATE",
"eventTime": "2021-12-14T12:34:56.789012Z",
"country": "ES",
"resourceType": "Party"
},
{
"eventType": "UPDATE",
"eventTime": "2021-12-14T12:34:56.789012Z",
"country": "ES",
"resourceType": "Party"
}
]
Created 02-27-2023 06:29 AM
Hi,
I dont think the EvaluateJsonPath and RouteOnAttribute will work properly since you have an array of json records in the the incoming flowfiles. You have to split the array using SplitJson processor and then use the EvaluateJsonPath->RouteOnAttributes to get the expected result. However there is better and more efficient option than using the mentioned processors (Split->Evaluate->Route), you can use just QueryRecords to filter the array and isolate the needed records. You can see example on how to use QueryRecords here: https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.19.1/org.apach...
If that helps , please accept solution.
Created 03-09-2023 08:49 AM
As @SAMSAL pointed out, queryrecord is the best and easiest method to use.
Here, i have created a sample flow for your use as pix attached.
I hope it helps.