JSONPath

Extract data from JSON files with JSONPath expressions


Description

Acts as library for other shortcuts, allowing them to parse JSON files using JSON Path expressions.

This is useful when you have a large JSON file or response from an API and need to pull out a specific piece of information.

Usage

Pass a dictionary with the following keys:

  • json: the JSON file to parse
  • expression: the JSONPath query

JSONPath documentation

JSONPath documentation and examples can be found here:

JSONPath - XPath for JSON

Example implementation

The shortcut example examines the JSON object below and displays the title of any book with a price greater than $10.

JSON

{
    "store": {
        "book": [
            {
                "category": "reference",
                "author": "Nigel Rees",
                "title": "Sayings of the Century",
                "price": 8.95
            },
            {
                "category": "fiction",
                "author": "Evelyn Waugh",
                "title": "Sword of Honour",
                "price": 12.99
            },
            {
                "category": "fiction",
                "author": "Herman Melville",
                "title": "Moby Dick",
                "isbn": "0-553-21311-3",
                "price": 8.99
            },
            {
                "category": "fiction",
                "author": "J. R. R. Tolkien",
                "title": "The Lord of the Rings",
                "isbn": "0-395-19395-8",
                "price": 22.99
            }
        ],
        "bicycle": {
            "color": "red",
            "price": 19.95
        }
    }
}

Example Shortcut

Download JSONPath Example shortcut


Latest Release Notes

1.0.1 - Jan. 13, 2019, 12:59 a.m.

Updated the name of the shortcut to prevent clashes


Past versions