{"id":13813645,"url":"https://github.com/jabbalaci/JSON-path","last_synced_at":"2025-05-15T00:33:56.210Z","repository":{"id":140437537,"uuid":"91623571","full_name":"jabbalaci/JSON-path","owner":"jabbalaci","description":"Find the path of a key / value in a JSON hierarchy easily.","archived":false,"fork":false,"pushed_at":"2023-02-28T14:51:00.000Z","size":35,"stargazers_count":93,"open_issues_count":0,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-08-04T04:04:26.164Z","etag":null,"topics":["dict","hierarchy","json","path","python","python3"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/jabbalaci.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":"2017-05-17T21:57:20.000Z","updated_at":"2024-08-04T04:04:29.168Z","dependencies_parsed_at":null,"dependency_job_id":"6d6d72d9-6b7c-4427-8afb-d22199c2e109","html_url":"https://github.com/jabbalaci/JSON-path","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2FJSON-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2FJSON-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2FJSON-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2FJSON-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jabbalaci","download_url":"https://codeload.github.com/jabbalaci/JSON-path/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225319288,"owners_count":17455741,"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":["dict","hierarchy","json","path","python","python3"],"created_at":"2024-08-04T04:01:24.185Z","updated_at":"2025-05-15T00:33:56.190Z","avatar_url":"https://github.com/jabbalaci.png","language":"Python","readme":"JSON Path\n=========\n\nFind the path of a key / value in a JSON hierarchy *easily*.\n\nMotivation\n----------\n\nWhen working with big and nested JSON files, sometimes\nit's very difficult to figure out the path of a key. You\nopen the JSON file in a text editor, find the key / value\npair you need, but then it can be a pain to get the full path of the key.\n\nExample\n-------\n\nConsider the following JSON file:\n\n```json\n{\n    \"a\": 1,\n    \"b\": {\n        \"c\": 2,\n        \"friends\": [\n            {\n                \"best\": \"Alice\"\n            },\n            {\n                \"second\": \"Bob\"\n            },\n            [5, 6, 7],\n            [\n                {\"one\": 1},\n                {\"two\": 2}\n            ]\n        ]\n    }\n}\n```\n\nJSON Path will traverse it recursively and print every\npath / value pair:\n\n```bash\n$ ./jsonpath.py samples/short.json\nroot['a'] =\u003e 1\nroot['b']['c'] =\u003e 2\nroot['b']['friends'][0]['best'] =\u003e 'Alice'\nroot['b']['friends'][1]['second'] =\u003e 'Bob'\nroot['b']['friends'][2][0] =\u003e 5\nroot['b']['friends'][2][1] =\u003e 6\nroot['b']['friends'][2][2] =\u003e 7\nroot['b']['friends'][3][0]['one'] =\u003e 1\nroot['b']['friends'][3][1]['two'] =\u003e 2\n```\n\nThe idea is to combine its usage with the Unix command\n`grep`. For instance, what's the path of the key that\nleads to Bob?\n\n```bash\n$ ./jsonpath.py samples/short.json | grep -i bob\nroot['b']['friends'][1]['second'] =\u003e 'Bob'\n```\n\nThen simply paste it in your application:\n\n```python\n\u003e\u003e\u003e d\n{'a': 1, 'b': {'c': 2, 'friends': [{'best': 'Alice'}, {'second': 'Bob'}, [5, 6, 7], [{'one': 1}, {'two': 2}]]}}\n\u003e\u003e\u003e d['b']['friends'][1]['second']\n'Bob'\n\u003e\u003e\u003e\n```\n\nRequirements\n------------\n\nThe project has no external dependencies. It only relies on the standard library.\n\nRelated Works\n-------------\n\n* [go-jsonpath](https://github.com/jabbalaci/go-jsonpath): a Go implementation of this project\n* See Chris Nielsen's excellent [JSON Visualization](http://chris.photobooks.com/json/default.htm)\nwebapp. Somewhat hidden feature, but if you click on an item in the table,\nyou'll get its path on the left side. I wanted something similar in the command line. Once I\nwas working with sensitive data, and I didn't want to paste them in a third-party webapp.\n* It seems Chris Nielsen's webapp is gone. However, someone saved it and it can be\nfound here: https://github.com/2x2xplz/json_visualizer . Online version: https://altearius.github.io/tools/json/index.html .\n* JSON Crack ([webpage](https://jsoncrack.com/), [GitHub link](https://github.com/AykutSarac/jsoncrack.com)).\nJSON Crack is a tool that generates graph diagrams from JSON objects.\nIt has an [online interface](https://jsoncrack.com/editor), but you can also install it\nas a VS Code extension.\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabbalaci%2FJSON-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjabbalaci%2FJSON-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabbalaci%2FJSON-path/lists"}