?
Solved

JSONPath and array

Posted on 2014-07-15
5
Medium Priority
?
308 Views
Last Modified: 2014-07-15
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
0
Comment
Question by:Anthony Lucia
  • 2
  • 2
5 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40197674
Your key name should not start with a number.  Javascript identifiers should not start with a number.
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 1000 total points
ID: 40197714
@DaveBaldwin

jsonlint.com seems to disagree with you.

Screenshot
Only because the "1" is a string, not a number   ; )
0
 
LVL 6

Accepted Solution

by:
J N earned 1000 total points
ID: 40197732
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40197986
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.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40197998
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.
0

Featured Post

Put Machine Learning to Work--Protect Your Clients

Machine learning means Smarter Cybersecurity™ Solutions.
As technology continues to advance, managing and analyzing massive data sets just can’t be accomplished by humans alone. It requires huge amounts of memory and storage, as well as the high-speed power of the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question