jsonapache-nifijsonpathjson-path-expression

NiFi EvaluateJsonPath array length


I have the following JSON:

{
    "hits": {
         "hits":[]
    }
}

(Some response from ElasticSearch).

I want to use the processor EvaluateJsonPath to get the length of hits.hits.

I tried the following expression:

$.hits.hits.length

But I get the following error:

FlowFile could not find path $['hits']['hits']['length'] for attribute key hits.: (That's the end of the error).

However, when checking online with JsonEvaluate sites it seems to work.

What's wrong with my expression?


Solution

  • It seems that there are different versions of JsonPath. For me, $.hits.hits.length() worked.