Apparently JSON has its own query language..JMESPATH

134 views
Skip to first unread message

Dimu Designs

unread,
May 20, 2019, 6:32:39 PM5/20/19
to google-apps-sc...@googlegroups.com
JSON happens to have its own query language in the form of JMESPATH.

I didn't know this was thing until fairly recently. I stumbled across it by chance while fishing for VS Code Extensions to help me wrangle with deeply nested JSON objects. 

Came across an awesome extension called JSON Transform for VS Code by Pine Wu. Basically it allows you to use JMESPATH queries to execute transformations on JSON files.

Outside of VSCode I also found a Javascript implementation of JMESPATH on github; I'm thinking I might be able to use these queries natively in Apps Script (probably need to transpile it down to ES5 to ensure compatibility). 

Should prove useful to folks that often work with complex JSON objects.

UPDATE

Looks like we can use the jmespath.js file from the github repo. Haven't tested it yet but the code does not seem to have any ES6 syntax so we should be able to just drop in into an Apps Script project as is (might want to run it through a minifier first to reduce the size). The Github repo has instructions on how to use the library. Have at it. 

UPDATE
And here's the minified version : jmespath.min.js

Faustino Rodriguez

unread,
May 21, 2019, 7:54:40 AM5/21/19
to Google Apps Script Community
me neither and it looks useful for a project I am still working on
the queries are a bit complicated though (before learning it)

Dimu Designs

unread,
May 22, 2019, 9:30:27 AM5/22/19
to Google Apps Script Community
Then you should check out the TUTORIALS. You'll pick up the query syntax in no time.
Reply all
Reply to author
Forward
0 new messages