JSONPATH Question

I’m attempting to use the JSONPATH transform to pull some info that I receive back from a server. I have no control over the server so I am forced to parse what I get. I’m at a loss on how to create the expression, hoping someone who is more familiar with this can help me.

The returned string looks like: {“num_locations”:1,“locations”:{“1234”:{“street1”:“abcd”,“street2”:“efgh”,“city”:“ijkl”,“state”:“mnop”,“postal_code”:“56789”}}}

What I need to extract is the “1234”. I’ve tried many different variants of the expression and I can’t find one that works. Any help is appreciated!

JSON is constructed of name Value pairs. The Name always goes on the left and the value goes on the right and they are separated by a :. JSONPATH can only return the value for a given name.

Given the JSON above, “1234” is a name, not a value so JSONPATH cannot return it. You will have to use some other transformation to extract that value. This REGEX might work:

REGEX(.*\"locations\":\{\"(.*)\".*)

You may need to double escape the { with \\{.