{"id":27019086,"url":"https://github.com/jabbalaci/go-jsonpath","last_synced_at":"2025-04-04T17:19:02.546Z","repository":{"id":93057761,"uuid":"607646485","full_name":"jabbalaci/go-jsonpath","owner":"jabbalaci","description":"Find the path of a key / value in a JSON hierarchy easily.","archived":false,"fork":false,"pushed_at":"2023-03-02T08:17:07.000Z","size":1391,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-06-20T22:33:00.279Z","etag":null,"topics":["cli","go","json"],"latest_commit_sha":null,"homepage":"","language":"Go","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":"2023-02-28T11:57:12.000Z","updated_at":"2023-04-05T12:16:11.000Z","dependencies_parsed_at":"2024-02-06T03:15:29.997Z","dependency_job_id":null,"html_url":"https://github.com/jabbalaci/go-jsonpath","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"5d56de5058278f14c0384363b6802ad81104659a"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2Fgo-jsonpath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2Fgo-jsonpath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2Fgo-jsonpath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2Fgo-jsonpath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jabbalaci","download_url":"https://codeload.github.com/jabbalaci/go-jsonpath/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217217,"owners_count":20903009,"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":["cli","go","json"],"created_at":"2025-04-04T17:19:01.874Z","updated_at":"2025-04-04T17:19:02.536Z","avatar_url":"https://github.com/jabbalaci.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"jpath\n=====\n\nFind the path of a key / value in a JSON hierarchy *easily*.\n\nThe original name of the project was \"JSON Path\", but\nit turned out that there is a specification called like this,\nso I renamed it to **jpath**. This project has nothing\nto do with the JSON path specification.\n\n(It turned out that IBM has a query language called [JPath](https://www.ibm.com/docs/en/dsm?topic=protocol-jpath). This project has nothing to do with that.)\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\nInstallation\n------------\n\n    $ go install github.com/jabbalaci/go-jsonpath/cmd/jpath@latest\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\njpath will traverse it recursively and print every\npath / value pair:\n\n```bash\n$ jpath 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$ jpath samples/short.json | grep -i bob\nroot[\"b\"][\"friends\"][1][\"second\"] =\u003e \"Bob\"\n```\n\nThen simply paste it in your application (Python example):\n\n```python\n\u003e\u003e\u003e import json\n\u003e\u003e\u003e\n\u003e\u003e\u003e f = open(\"samples/short.json\")\n\u003e\u003e\u003e d = json.load(f)\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\nRelated Works\n-------------\n\n* [JSON-path](https://github.com/jabbalaci/JSON-path): my original Python implementation. This project is the same,\nre-written in Go.\n* [gron](https://github.com/tomnomnom/gron): gron makes\nJSON greppable. gron can do a lot more than jpath, but\nwhen I made jpath I didn't know about gron.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabbalaci%2Fgo-jsonpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjabbalaci%2Fgo-jsonpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabbalaci%2Fgo-jsonpath/lists"}