JSON parse issue in Enrich Data by Webservice

sgenzer
sgenzer
Altair Employee
edited November 2024 in Community Q&A

Hi...I have never been able to send commands such as this via the Enrich Data by Webservice when using the JSON parser:  $..foo[1]   Often I want to find the 2nd, 3rd or whatever.  I am using the notation as documented here.  Ideas?  Attached is a sample JSON file where I want to get $..lat, $..lat[1], $..lat[2] and so on.

 

[note: the attached file is a .zip file because this community site does not accept .json or .txt suffixes  :)  ]

 

Thanks.

Scott

Best Answer

  • BalazsBaranyRM
    BalazsBaranyRM New Altair Community Member
    Answer ✓

    Are you sure your JSONPath is correct?

     

    I always use the online parser at jsonpath.com for checking my expressions. In your case, the following expressions work:

     

    $.results[*].geometry.location.lat (all latitudes)

    $.results[0].geometry.location.lat (first latitude)

     

    Regards,

    Balázs

Answers

  • BalazsBaranyRM
    BalazsBaranyRM New Altair Community Member
    Answer ✓

    Are you sure your JSONPath is correct?

     

    I always use the online parser at jsonpath.com for checking my expressions. In your case, the following expressions work:

     

    $.results[*].geometry.location.lat (all latitudes)

    $.results[0].geometry.location.lat (first latitude)

     

    Regards,

    Balázs

  • sgenzer
    sgenzer
    Altair Employee

    hmm very interesting.  Thank you @BalazsBarany.  I was using http://goessner.net/articles/JsonPath/ which has always helped but clearly not aligned with the JSON parser used here.  Another good bookmark to keep on hand.

     

    Scott

     

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.