I am trying to extract the county by checking for type "administrative_area_level_2". Since types is an array, I need to check on index 0. I have also tried using indexOf, but with no success.
Here is what my jsonpath looks like:
$.address_components[?(@.types[0] == 'administrative_area_level_2')].long_name
.. and here is the payload.
{ "address_components" : [ { "long_name" : "94043", "short_name" : "94043", "types" : [ "postal_code" ] }, { "long_name" : "Mountain View", "short_name" : "Mountain View", "types" : [ "locality", "political" ] }, { "long_name" : "Santa Clara County", "short_name" : "Santa Clara County", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "California", "short_name" : "CA", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] } ] }
When I run it in a testing tool (ex. jsonpath.com), it returns "Santa Clara County", but I am unable to see the same result when I try to extract it in Apigee. Am I missing something? Any help would be greatly appreciated.
This could be because Edge is using an old version of the JSONPath library. An update is in the works.
See https://community.apigee.com/questions/51302/json-range-operator-not-working.html