Or should be that be JsonPath? What­ev­er, it’s a tool I’ve been us­ing late­ly and gen­er­al­ly like. But it could use a lit­tle work.

The last project I worked on, Step Func­tions, has a JSON DSL for State Machi­nes, which makes use of JSONPath (see Paths and In­put and Out­put Pro­cesing) to solve a tricky prob­lem in a way that peo­ple seem to find easy to un­der­stand and use.

Ear­ly on in that project we adopt­ed the Jay­way JsonPath li­brary and it seems to most­ly Just Work.

But, we’ve had a few ques­tions from cus­tomer along the lines of “Your ser­vice re­ject­ed my In­putPath, but it looks OK to me.”

Which rais­es the ques­tion: What is a le­gal JsonPath, any­how?

To the ex­tent there’s an “official” def­i­ni­tion, the most ob­vi­ous can­di­date would be Ste­fan Goessner’s JSONPath - XPath for JSON. Stan­dards wonks will sneer at it, not a shred of BNF in sight. But I like it, be­cause it ap­plies the most im­por­tant les­son from Mark Pilgrim’s im­mor­tal Morons and Ass­holes es­say: Have lots of ex­am­ples.

Hav­ing said that, it’s kind of skin­ny. And if you go back to that Jay­way JsonPath spec and start scrolling the README.md, well, you can keep scrolling and scrolling, and there’s a lot of good­ness there.

But stil­l, is $.blog-entry a valid JSONPath? Or should you have to say $['blog-entry']? Be­cause blog-entry is not, af­ter al­l, a JavaScript “Name” con­struc­t.

For the pur­pos­es of AWS Step Func­tion­s, JsonPath means what Jay­way says it mean­s. But I’d be hap­pi­er if there were an RFC or some­thing be­cause, good as Jay­way is, peo­ple do [*­gasp*] write code in lan­guages oth­er than Java.

So, an RFC may­be? The idea’s not crazy.

Cap­i­tal­iza­tion · Let me set­tle one dis­pute right here: Ste­fan Goess­ner says “JSONPath”, Jay­way says “JsonPath”. Stefan’s right, be­cause it’s called JSON not Json, and by the anal­o­gy with XPath.


Comment feed for ongoing:Comments feed

From: Bob Monsour (Apr 14 2017, at 10:27)

Pardon me for being an asshole at the moment, but the 2nd link for the Jayway JsonPath is coughing. The first one works beautifully.


From: anonymous (Apr 14 2017, at 10:53)

There is JSON Pointer (RFC 6901), but it's a lot less powerful than XPath or JsonPath, and I'm not aware of any mainstream usage of that spec.


From: Jilles van Gurp (Apr 14 2017, at 11:40)

I've been using a command line tool called jq a lot lately to pick apart json that comes back from AWS. I guess that's pretty close to having xpath like support for json already.

For example this nice one liner dumps the names of the various stacks we have running with cloud formation:

aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETE --stack-status-filter UPDATE_COMPLETE --max-items 100 | jq --raw-output '.StackSummaries[].StackName'

Very useful if you have to deal with big blobs of json coming from wherever.


From: Clayton Coleman (Apr 14 2017, at 13:48)

A formal spec for JSONPath would be very useful. For Kubernetes we have a strong desire to use JSONPath for adhoc referential integrity and loose coupling between resources, but the lack of a formal spec has meant we have been cautious about its use. We would be eager consumers of a formal spec and work to provide a Go library (which we have informally today).


From: Marcus Ramberg (Apr 15 2017, at 23:08)

The Mojolicious web framework implements JSON pointer support: http://mojolicious.org/perldoc/Mojo/JSON/Pointer

We would really like it if a more powerful mechanism was standardized though.


From: Sylvie (Apr 18 2017, at 13:12)

+1 to Jilles van Gurp's comment: "jq" is awesome.

I needed to extract the "id" attribute from one of these:


"size": 6,

"limit": 25,

"isLastPage": true,

"values": [


"id": 504,

"type": "read-only",

"matcher": {

"id": "development",

"displayId": "Development",

"type": {


"name": "Branching model branch"


"active": true


"users": [],

"groups": [],

"accessKeys": []


Here was the jq query for that:

'.values[] | select(.type=="read-only" and .matcher.id=="development") | .id '

Out pops 504 ! :-D


author · Dad · software · colophon · rights
picture of the day
April 14, 2017
· Technology (81 fragments)
· · Internet (108 more)

By .

I am an employee
of Amazon.com, but
the opinions expressed here
are my own, and no other party
necessarily agrees with them.

A full disclosure of my
professional interests is
on the author page.