{"id":13541243,"url":"https://github.com/fdncred/nu_plugin_json_path","last_synced_at":"2025-03-17T02:31:05.752Z","repository":{"id":68653946,"uuid":"603943684","full_name":"fdncred/nu_plugin_json_path","owner":"fdncred","description":"A nushell plugin for parsing json that uses the json path specification.","archived":false,"fork":false,"pushed_at":"2025-02-10T15:39:29.000Z","size":98,"stargazers_count":18,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-27T16:39:43.290Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fdncred.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-20T01:51:05.000Z","updated_at":"2025-02-10T15:39:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"f9f30ea4-e9eb-4d34-b6c8-dc5056325be5","html_url":"https://github.com/fdncred/nu_plugin_json_path","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdncred%2Fnu_plugin_json_path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdncred%2Fnu_plugin_json_path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdncred%2Fnu_plugin_json_path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdncred%2Fnu_plugin_json_path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fdncred","download_url":"https://codeload.github.com/fdncred/nu_plugin_json_path/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243836991,"owners_count":20355810,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T10:00:42.277Z","updated_at":"2025-03-17T02:31:05.277Z","avatar_url":"https://github.com/fdncred.png","language":"Rust","readme":"# nu_plugin_json_path\n\nThis [nushell](https://github.com/nushell/nushell) plugin is an attempt to enable the use of `JSONPath`. You can read more about JSONPath in the specification [here](https://www.ietf.org/archive/id/draft-ietf-jsonpath-base-10.html).\n\n## Example Input\n\nThis json file is taken from the JSONPath link above.\n\n```json\n{\n  \"store\": {\n    \"book\": [\n      { \"category\": \"reference\",\n        \"author\": \"Nigel Rees\",\n        \"title\": \"Sayings of the Century\",\n        \"price\": 8.95\n      },\n      { \"category\": \"fiction\",\n        \"author\": \"Evelyn Waugh\",\n        \"title\": \"Sword of Honour\",\n        \"price\": 12.99\n      },\n      { \"category\": \"fiction\",\n        \"author\": \"Herman Melville\",\n        \"title\": \"Moby Dick\",\n        \"isbn\": \"0-553-21311-3\",\n        \"price\": 8.99\n      },\n      { \"category\": \"fiction\",\n        \"author\": \"J. R. R. Tolkien\",\n        \"title\": \"The Lord of the Rings\",\n        \"isbn\": \"0-395-19395-8\",\n        \"price\": 22.99\n      }\n    ],\n    \"bicycle\": {\n      \"color\": \"red\",\n      \"price\": 399\n    }\n  }\n}\n```\n## Syntax and Description\n\nThis table shows some example JSONPath syntax and the intended results for testing below.\n\n|#|JSONPath\t|Intended result|\n|-|-|-|\n|1|`$.store.book[*].author`\t|the authors of all books in the store|\n|2|`$..author`\t|all authors|\n|3|`$.store.*`\t|all things in store, which are some books and a red bicycle|\n|4|`$.store..price`\t|the prices of everything in the store|\n|5|`$..book[2]`\t|the third book|\n|6|`$..book[-1]`\t|the last book in order|\n|7|`$..book[0,1]`|the first two books|\n|8|`$..book[:2]`\t|the first two books|\n|9|`$..book[?(@.isbn)]`\t|all books with an ISBN number|\n|10|`$..book[?(@.price\u003c10)]`\t|all books cheaper than 10|\n|11|`$..*`\t|all member values and array elements |contained in the input value\n\n## Plugin Examples\n\nI saved the above json in a file named test.json, which is also in the repository.\n\n### Example 1\n\n```sh\nopen test.json | json path '$.store.book[*].author'\n```\n```\n╭───┬──────────────────╮\n│ 0 │ Nigel Rees       │\n│ 1 │ Evelyn Waugh     │\n│ 2 │ Herman Melville  │\n│ 3 │ J. R. R. Tolkien │\n╰───┴──────────────────╯\n```\n\n### Example 2\n\n```sh\nopen test.json | json path '$..author'\n```\n```\n╭───┬──────────────────╮\n│ 0 │ Nigel Rees       │\n│ 1 │ Evelyn Waugh     │\n│ 2 │ Herman Melville  │\n│ 3 │ J. R. R. Tolkien │\n╰───┴──────────────────╯\n```\n\n### Example 3\n\n```sh\nopen test.json | json path '$.store.*'\n```\n```\n╭───┬───────────────────╮\n│ 0 │ {record 2 fields} │\n│ 1 │ [table 4 rows]    │\n╰───┴───────────────────╯\n```\n```sh\nopen test.json | json path '$.store.*' | get 0\n```\n```\n╭───────┬─────╮\n│ color │ red │\n│ price │ 399 │\n╰───────┴─────╯\n```\n```sh\nopen test.json | json path '$.store.*' | get 1\n```\n```\n╭───┬──────────────────┬───────────┬───────┬────────────────────────┬───────────────╮\n│ # │      author      │ category  │ price │         title          │     isbn      │\n├───┼──────────────────┼───────────┼───────┼────────────────────────┼───────────────┤\n│ 0 │ Nigel Rees       │ reference │  8.95 │ Sayings of the Century │            ❎ │\n│ 1 │ Evelyn Waugh     │ fiction   │ 12.99 │ Sword of Honour        │            ❎ │\n│ 2 │ Herman Melville  │ fiction   │  8.99 │ Moby Dick              │ 0-553-21311-3 │\n│ 3 │ J. R. R. Tolkien │ fiction   │ 22.99 │ The Lord of the Rings  │ 0-395-19395-8 │\n╰───┴──────────────────┴───────────┴───────┴────────────────────────┴───────────────╯\n```\n### Example 4\n\n```sh\nopen test.json | json path '$.store..price'\n```\n```\n╭───┬───────╮\n│ 0 │   399 │\n│ 1 │  8.95 │\n│ 2 │ 12.99 │\n│ 3 │  8.99 │\n│ 4 │ 22.99 │\n╰───┴───────╯\n```\n\n### Example 5\n\n```sh\nopen test.json | json path '$..book[2]'\n```\n```\n╭───┬─────────────────┬──────────┬───────────────┬───────┬───────────╮\n│ # │     author      │ category │     isbn      │ price │   title   │\n├───┼─────────────────┼──────────┼───────────────┼───────┼───────────┤\n│ 0 │ Herman Melville │ fiction  │ 0-553-21311-3 │  8.99 │ Moby Dick │\n╰───┴─────────────────┴──────────┴───────────────┴───────┴───────────╯\n```\n\n### Example 6\n\n```sh\nopen test.json | json path '$..book[-1]'\n```\n```\n╭───┬──────────────────┬──────────┬───────────────┬───────┬───────────────────────╮\n│ # │      author      │ category │     isbn      │ price │         title         │\n├───┼──────────────────┼──────────┼───────────────┼───────┼───────────────────────┤\n│ 0 │ J. R. R. Tolkien │ fiction  │ 0-395-19395-8 │ 22.99 │ The Lord of the Rings │\n╰───┴──────────────────┴──────────┴───────────────┴───────┴───────────────────────╯\n```\n\n### Example 7\n\n```sh\nopen test.json | json path '$..book[0,1]'\n```\n```\n╭───┬──────────────┬───────────┬───────┬────────────────────────╮\n│ # │    author    │ category  │ price │         title          │\n├───┼──────────────┼───────────┼───────┼────────────────────────┤\n│ 0 │ Nigel Rees   │ reference │  8.95 │ Sayings of the Century │\n│ 1 │ Evelyn Waugh │ fiction   │ 12.99 │ Sword of Honour        │\n╰───┴──────────────┴───────────┴───────┴────────────────────────╯\n```\n\n### Example 8\n\n```sh\nopen test.json | json path '$..book[:2]'\n```\n```\n╭───┬──────────────┬───────────┬───────┬────────────────────────╮\n│ # │    author    │ category  │ price │         title          │\n├───┼──────────────┼───────────┼───────┼────────────────────────┤\n│ 0 │ Nigel Rees   │ reference │  8.95 │ Sayings of the Century │\n│ 1 │ Evelyn Waugh │ fiction   │ 12.99 │ Sword of Honour        │\n╰───┴──────────────┴───────────┴───────┴────────────────────────╯\n```\n\n### Example 9\n\n```sh\nopen test.json | json path '$..book[?(@.isbn)]'\n```\n```\n╭───┬──────────────────┬──────────┬───────────────┬───────┬───────────────────────╮\n│ # │      author      │ category │     isbn      │ price │         title         │\n├───┼──────────────────┼──────────┼───────────────┼───────┼───────────────────────┤\n│ 0 │ Herman Melville  │ fiction  │ 0-553-21311-3 │  8.99 │ Moby Dick             │\n│ 1 │ J. R. R. Tolkien │ fiction  │ 0-395-19395-8 │ 22.99 │ The Lord of the Rings │\n╰───┴──────────────────┴──────────┴───────────────┴───────┴───────────────────────╯\n```\n### Example 10\n\n```sh\nopen test.json | json path '$..book[?(@.price\u003c10)]'\n```\n```\n╭───┬─────────────────┬───────────┬───────┬────────────────────────┬───────────────╮\n│ # │     author      │ category  │ price │         title          │     isbn      │\n├───┼─────────────────┼───────────┼───────┼────────────────────────┼───────────────┤\n│ 0 │ Nigel Rees      │ reference │  8.95 │ Sayings of the Century │            ❎ │\n│ 1 │ Herman Melville │ fiction   │  8.99 │ Moby Dick              │ 0-553-21311-3 │\n╰───┴─────────────────┴───────────┴───────┴────────────────────────┴───────────────╯\n```\n\n### Example 11\n\n```sh\nopen test.json | json path '$..*'\n```\n```\n╭────┬────────────────────────╮\n│  0 │ {record 2 fields}      │\n│  1 │ {record 2 fields}      │\n│  2 │ [table 4 rows]         │\n│  3 │ red                    │\n│  4 │                    399 │\n│  5 │ {record 4 fields}      │\n│  6 │ {record 4 fields}      │\n│  7 │ {record 5 fields}      │\n│  8 │ {record 5 fields}      │\n│  9 │ Nigel Rees             │\n│ 10 │ reference              │\n│ 11 │                   8.95 │\n│ 12 │ Sayings of the Century │\n│ 13 │ Evelyn Waugh           │\n│ 14 │ fiction                │\n│ 15 │                  12.99 │\n│ 16 │ Sword of Honour        │\n│ 17 │ Herman Melville        │\n│ 18 │ fiction                │\n│ 19 │ 0-553-21311-3          │\n│ 20 │                   8.99 │\n│ 21 │ Moby Dick              │\n│ 22 │ J. R. R. Tolkien       │\n│ 23 │ fiction                │\n│ 24 │ 0-395-19395-8          │\n│ 25 │                  22.99 │\n│ 26 │ The Lord of the Rings  │\n╰────┴────────────────────────╯\n```\n# Building, Installing, and Registering\n\nSince this plugin isn't published on crates.io, you will have to have the nushell repository cloned in order to build it.\n\nThis is a nushell script provided in [the first issue](https://github.com/fdncred/nu_plugin_json_path/issues/1). In that issue @amtoine explains, \"as my repos are located in `$env.GIT_REPOS_HOME/\u003chost\u003e/\u003cowner\u003e/\u003crepo\u003e`, i had to run the following\".\n\n```sh\n[nu-plugin nu-protocol] | each {|crate|\n    let local = ($env.GIT_REPOS_HOME | path join \"github.com\" \"nushell\" \"nushell\" \"crates\" $crate)\n    cargo add $crate --path $local\n}\n```\n\nOnce the cargo.toml is updated, all you have to do is `cargo install --path .` and then, from within nushell do a `register /path/to/nu_plugin_json_path`.\n\nGood luck!","funding_links":[],"categories":["Plugins"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdncred%2Fnu_plugin_json_path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffdncred%2Fnu_plugin_json_path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdncred%2Fnu_plugin_json_path/lists"}