JSONPAth expression tester

I am reading about JSONPath script from th efollowing site

http://goessner.net/articles/JsonPath/

Open in new window


So I went to the JSON tester site

http://jsonpath.curiousconcept.com/

Open in new window


and entered the following into the JSON Data seciont

{ "identification" : "AlphaBeta" }

Open in new window


Then I entered the following into the JSON Expression section:

$.identification

Open in new window


That resulted in the following in the 'Results' section:

[
   "AlphaBeta"
]

Open in new window


My question:  Why does it place a begining bracket '[', and a closing bracket '].

Why doesnt it just report the following:

   "AlphaBeta"

Open in new window

Anthony LuciaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexandre SimõesManager / Technology SpecialistCommented:
I'm no expert on that jsonPath but it seems like the result can be a set of matches.
I mean, your "query" can have multiple result, that's why the result is a collection.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Alexandre SimõesManager / Technology SpecialistCommented:
Although you don't need to use fancy libraries for this specific case you're doing.
For your JSON object you can simply do:
var json = { "identification" : "AlphaBeta" };

// get identification
var option1 = json.identification;    // returns: AlphaBeta
var option2 = json['identification']; // returns: AlphaBeta

// if you ask for a property that doesn't exist you'll get undefined
var option1 = json.name;    // returns: undefined
var option2 = json['name']; // returns: undefined

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Services

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.