{"id":24625148,"url":"https://github.com/johnmccabe/jsonpath","last_synced_at":"2026-05-21T04:01:19.536Z","repository":{"id":57501419,"uuid":"126473982","full_name":"johnmccabe/jsonpath","owner":"johnmccabe","description":"Fork of NodePrime/jsonpath which has been deleted (March2018)","archived":false,"fork":false,"pushed_at":"2018-03-23T11:08:21.000Z","size":154,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-01T05:25:06.398Z","etag":null,"topics":[],"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/johnmccabe.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}},"created_at":"2018-03-23T11:07:46.000Z","updated_at":"2018-03-23T11:08:57.000Z","dependencies_parsed_at":"2022-09-06T22:32:04.007Z","dependency_job_id":null,"html_url":"https://github.com/johnmccabe/jsonpath","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/johnmccabe/jsonpath","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnmccabe%2Fjsonpath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnmccabe%2Fjsonpath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnmccabe%2Fjsonpath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnmccabe%2Fjsonpath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnmccabe","download_url":"https://codeload.github.com/johnmccabe/jsonpath/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnmccabe%2Fjsonpath/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33288119,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T02:57:32.698Z","status":"ssl_error","status_checked_at":"2026-05-21T02:57:31.990Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2025-01-25T04:13:10.305Z","updated_at":"2026-05-21T04:01:19.520Z","avatar_url":"https://github.com/johnmccabe.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Coverage](http://gocover.io/_badge/github.com/NodePrime/jsonpath)](http://gocover.io/github.com/NodePrime/jsonpath)\n# jsonpath  \n  \njsonpath is used to pull values out of a JSON document without unmarshalling the string into an object.  At the loss of post-parse random access and conversion to primitive types, you gain faster return speeds and lower memory utilization.  If the value you want is located near the start of the json, the evaluator will terminate after reaching and recording its destination.  \n  \nThe evaluator can be initialized with several paths, so you can retrieve multiple sections of the document with just one scan.  Naturally, when all paths have been reached, the evaluator will early terminate.  \n  \nFor each value returned by a path, you'll also get the keys \u0026 indexes needed to reach that value.  Use the `keys` flag to view this in the CLI.  The Go package will return an `[]interface{}` of length `n` with indexes `0 - (n-2)` being the keys and the value at index `n-1`.  \n  \n### CLI   \n```shell\ngo get github.com/NodePrime/jsonpath/cli/jsonpath\ncat yourData.json | jsonpath -k -p '$.Items[*].title+'\n```\n\n##### Usage  \n```shell\n-f, --file=\"\": Path to json file  \n-j, --json=\"\": JSON text  \n-k, --keys=false: Print keys \u0026 indexes that lead to value  \n-p, --path=[]: One or more paths to target in JSON\n```\n\n  \n### Go Package  \ngo get github.com/NodePrime/jsonpath  \n \n```go\npaths, err := jsonpath.ParsePaths(pathStrings ...string) {\n```  \n\n```go\neval, err := jsonpath.EvalPathsInBytes(json []byte, paths) \n// OR\neval, err := jsonpath.EvalPathsInReader(r io.Reader, paths)\n```\n\nthen  \n```go  \nfor {\n\tif result, ok := eval.Next(); ok {\n\t\tfmt.Println(result.Pretty(true)) // true -\u003e show keys in pretty string\n\t} else {\n\t\tbreak\n\t}\n}\nif eval.Error != nil {\n\treturn eval.Error\n}\n```  \n\n`eval.Next()` will traverse JSON until another value is found.  This has the potential of traversing the entire JSON document in an attempt to find one.  If you prefer to have more control over traversing, use the `eval.Iterate()` method.  It will return after every scanned JSON token and return `([]*Result, bool)`.  This array will usually be empty, but occasionally contain results.  \n     \n### Path Syntax  \nAll paths start from the root node `$`.  Similar to getting properties in a JavaScript object, a period `.title` or brackets `[\"title\"]` are used.  \n  \nSyntax|Meaning|Examples\n------|-------|-------\n`$`|root of doc|  \n`.`|property selector |`$.Items`\n`[\"abc\"]`|quoted property selector|`$[\"Items\"]`\n`*`|wildcard property name|`$.*` \n`[n]`|Nth index of array|`[0]` `[1]`\n`[n:m]`|Nth index to m-1 index (same as Go slicing)|`[0:1]` `[2:5]`\n`[n:]`|Nth index to end of array|`[1:]` `[2:]`\n`[*]`|wildcard index of array|`[*]`\n`+`|get value at end of path|`$.title+`\n`?(expression)`|where clause (expression can reference current json node with @)|`?(@.title == \"ABC\")`\n  \n  \nExpressions  \n- paths (that start from current node `@`)\n- numbers (integers, floats, scientific notation)\n- mathematical operators (+ - / * ^)\n- numerical comparisos (\u003c \u003c= \u003e \u003e=)\n- logic operators (\u0026\u0026 || == !=)\n- parentheses `(2 \u003c (3 * 5))`\n- static values like (`true`, `false`)\n- `@.value \u003e 0.5`\n\nExample: this will only return tags of all items that match this expression.\n`$.Items[*]?(@.title == \"A Tale of Two Cities\").tags`  \n\n   \nExample: \n```javascript\n{  \n\t\"Items\":   \n\t\t[  \n\t\t\t{  \n\t\t\t\t\"title\": \"A Midsummer Night's Dream\",  \n\t\t\t\t\"tags\":[  \n\t\t\t\t\t\"comedy\",  \n\t\t\t\t\t\"shakespeare\",  \n\t\t\t\t\t\"play\"  \n\t\t\t\t]  \n\t\t\t},{  \n\t\t\t\t\"title\": \"A Tale of Two Cities\",  \n\t\t\t\t\"tags\":[  \n\t\t\t\t\t\"french\",  \n\t\t\t\t\t\"revolution\",  \n\t\t\t\t\t\"london\"  \n\t\t\t\t]  \n\t\t\t}  \n\t\t]  \n} \n```\n\t\nExample Paths:   \n*CLI*  \n```shell\njsonpath --file=example.json --path='$.Items[*].tags[*]+' --keys\n```   \n\"Items\"\t0\t\"tags\"\t0\t\"comedy\"  \n\"Items\"\t0\t\"tags\"\t1\t\"shakespeare\"  \n\"Items\"\t0\t\"tags\"\t2\t\"play\"  \n\"Items\"\t1\t\"tags\"\t0\t\"french\"  \n\"Items\"\t1\t\"tags\"\t1\t\"revolution\"  \n\"Items\"\t1\t\"tags\"\t2\t\"london\"  \n  \n*Paths*  \n`$.Items[*].title+`   \n... \"A Midsummer Night's Dream\"   \n... \"A Tale of Two Cities\"   \n  \n`$.Items[*].tags+`    \n... [\"comedy\",\"shakespeare\",\"play\"]  \n... [\"french\",\"revolution\",\"london\"]  \n  \n`$.Items[*].tags[*]+`  \n... \"comedy\"  \n... \"shakespeare\"  \n... \"play\"  \n... \"french\"  \n... \"revolution\"  \n...  \"london\"  \n  \n... = keys/indexes of path  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnmccabe%2Fjsonpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnmccabe%2Fjsonpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnmccabe%2Fjsonpath/lists"}