“JSONPath.gs

·

JSONPath is a wonderful little library if you regularly work with JSON. Because it’s neatly packed and avaialable as a JavaScript version, what easier to do than to create a Google Apps Script version of it.

Thought - done. You find the Library with the following ID M2kt1U7LL_2rAYMhFKpXAlpyRHZGAjJhz to add it to your projects.

To use it in your code, just call it like this:

JSONPath.apply(obj, expr, arg);

Where the parameters and the return value are as follows:

parameters:

obj (object|array): Object representing the JSON structure.

expr (string): JSONPath expression string.

args (object|undefined): Object controlling path evaluation and output. Currently only one member is supported.

args.resultType (“VALUE”|“PATH”): causes the result to be either matching values (default) or normalized path expressions.

return value:

(array|false): Array holding either values or normalized path expressions matching the input path expression, which can be used for lazy evaluation. false in case of no match.

Enjoy!

Comments.

No comments. Be the first to add one!
Add a comment.
We'll never share your email with anyone else. We use the Gravatar system to pull in pictures based on an anonymous hash.
Once you submit your comment, it will be moderated and then show up here shortly after.