Link to home
Start Free TrialLog in
Avatar of Anthony Lucia
Anthony Lucia

asked on

JSONPath and array

I have the following JSON object.

[{"1":444}]

Open in new window


As you can see, its encased in brackets, and therefore an array.

If there were no brackets I could easily get the 444 value with the following command

$.1

Open in new window


However, I do not seem to be able to get the value of the from JSONPath with the enclosed brackets included in the JSON object.

How do I format a JSONPath statement that will return 444 from the JSON object of

[{"1":444}]

Open in new window


Thanks
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Your key name should not start with a number.  Javascript identifiers should not start with a number.
SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If the "1" that is a string gets used as a name for a variable in javascript, then it will be wrong.  I'm pretty sure that's my point.  Identifiers in javascript such as variable names and 'id's for HTML elements are not supposed to start with a number.  I suspect that applies to names used as identifiers in arrays too.
If the "1" that is a string gets used as a name for a variable in javascript, then it will be wrong.
That I do agree with.