Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Nifi Jsonpathreader is unable to extract the json array value on matched string

avatar
Explorer

Hi Team,

I am facing the issue, while trying to fetch the value from jsonpathreader with avroschema attributes as below.

json reading from avro schema with jsonpathreader, and want to fetch home number with expression $.phoneNumbers[?(@.type=="home")].number. However, it is getting failed.

Please help on this.

 

{
  "firstName": "John",
  "lastName": "Smith",
  "isAlive": true,
  "age": 25,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021-3100"
  },
  "phoneNumbers": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "office",
      "number": "646 555-4567"
    }
  ],
  "children": [],
  "spouse": null
}

 

1 REPLY 1

avatar

@Kondaji wrote:

Hi Team,

I am facing the issue, while trying to fetch the value from jsonpathreader with avroschema attributes as below.

json reading from avro schema with jsonpathreader, and want to fetch home number with expression $.phoneNumbers[?(@.type=="home")].number. However, it is getting failed. Socrates GM

Please help on this.

 

{
  "firstName": "John",
  "lastName": "Smith",
  "isAlive": true,
  "age": 25,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021-3100"
  },
  "phoneNumbers": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "office",
      "number": "646 555-4567"
    }
  ],
  "children": [],
  "spouse": null
}

 


Hello,

I understand your frustration with this issue. It seems like the JSONPath expression you’re using should work, but there might be a few things to check:

Ensure JSONPathReader is correctly configured: Verify that the JSONPathReader is set up properly in your NiFi flow.
Check the Avro Schema: Make sure the Avro schema matches the structure of your JSON data.
Validate JSONPath Expression: Double-check the JSONPath expression $.phoneNumbers[?(@.type=="home")].number for any syntax errors.



Hope this will help you.
Best regards,
florence0239