JSONPath referencing a JSON array

Posted on 2014-07-15
Last Modified: 2014-07-16
I have the following JSON object.


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 123 value with the following command


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.

I checked on a validator and the JSON object is valid.  I looked up several JSONPath sites, but I could not find out how to dereference this strange array

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


Open in new window

Question by:Anthony Lucia
    LVL 1

    Accepted Solution

    In plain Javascript you could do the following:
    var foo = [{"ID":"123"}];
    var ID = foo[0].ID;

    Open in new window

    foo[0] will reference to the JSON object in the array object, being the first element (index 0), then inside the JSON Object you can use the key of the key value pairs to return it's value.

    Author Closing Comment

    by:Anthony Lucia
    Thanks to your help I was able to get this in pure JSONPath with the following:


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    The task of choosing a web design company to build a website for your business should never be taken in a light manner. Provided the fact that your website will act as a representative to your business and will be responsible for imposing an online …
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now