{"id":37157119,"url":"https://github.com/ofabricio/jsqr","last_synced_at":"2026-01-14T18:42:14.321Z","repository":{"id":264158477,"uuid":"892359637","full_name":"ofabricio/jsqr","owner":"ofabricio","description":"Query or evaluate JSON values","archived":false,"fork":false,"pushed_at":"2024-12-13T10:15:56.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-13T11:24:11.058Z","etag":null,"topics":["json","json-query","query"],"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/ofabricio.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":"2024-11-22T00:55:23.000Z","updated_at":"2024-12-13T10:16:01.000Z","dependencies_parsed_at":"2024-11-22T11:28:45.193Z","dependency_job_id":null,"html_url":"https://github.com/ofabricio/jsqr","commit_stats":null,"previous_names":["ofabricio/jsqr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ofabricio/jsqr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofabricio%2Fjsqr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofabricio%2Fjsqr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofabricio%2Fjsqr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofabricio%2Fjsqr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ofabricio","download_url":"https://codeload.github.com/ofabricio/jsqr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofabricio%2Fjsqr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28430880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T16:38:47.836Z","status":"ssl_error","status_checked_at":"2026-01-14T16:34:59.695Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["json","json-query","query"],"created_at":"2026-01-14T18:42:13.624Z","updated_at":"2026-01-14T18:42:14.313Z","avatar_url":"https://github.com/ofabricio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsqr\n\nQuery or evaluate JSON values.\n\n### Install\n\n```\ngo get github.com/ofabricio/jsqr\n```\n\n# Example\n\n([Playground](https://go.dev/play/p/VoDXHRge1jF))\n\n```go\npackage main\n\nimport \"github.com/ofabricio/jsqr\"\n\nfunc main() {\n\n    j := []byte(`\n        {\n            \"data\": { \"store\": \"Grocery\" },\n            \"tags\": [\n                { \"name\": \"Fruit\", \"items\": [{ \"name\": \"Apple\" }] },\n                { \"name\": \"Snack\", \"items\": [{ \"name\": \"Chips\" }] },\n                { \"name\": \"Drink\", \"items\": [{ \"name\": \"Water\" }, { \"name\": \"Wine\" }] }\n            ]\n        }\n    `)\n\n    a := jsqr.Get(j, `.data.store`)\n    b := jsqr.Get(j, `.tags.[1].name == \"Snack\"`)\n    c := jsqr.Get(j, `.tags.[ .name == \"Drink\" ].items.[0].name.(upper)`)\n\n    fmt.Println(a) // \"Grocery\"\n    fmt.Println(b) // true\n    fmt.Println(c) // \"WATER\"\n}\n```\n\nAlso works with Go types:\n\n([Playground](https://go.dev/play/p/F5wk8pc_gkW))\n\n```go\npackage main\n\nimport \"github.com/ofabricio/jsqr\"\n\nfunc main() {\n\n    s := Store{\n        Data: Data{\n            Name: \"Grocery\",\n        },\n        Tags: []Tags{\n            {Name: \"Fruit\", Items: []Item{{Name: \"Apple\"}}},\n            {Name: \"Snack\", Items: []Item{{Name: \"Chips\"}}},\n            {Name: \"Drink\", Items: []Item{{Name: \"Water\"}, {Name: \"Wine\"}}},\n        },\n    }\n\n    a := jsqr.GetStruct(s, `.Data.Name`)\n    b := jsqr.GetStruct(s, `.Tags.[1].Name == \"Snack\"`)\n    c := jsqr.GetStruct(s, `.Tags.[ .Name == \"Drink\" ].Items.[0].Name.(upper)`)\n\n    fmt.Println(a) // \"Grocery\"\n    fmt.Println(b) // true\n    fmt.Println(c) // \"WATER\"\n}\n```\n\nNote that `jsqr.Get*(v, expr)` compiles the expression each time it is called. Avoid it with `jsqr.Compile(expr)`.\n\n# Documentation\n\n| Expression | Description |\n| --- | --- | \n| `.` | Returns the current context. |\n| `.a` | Returns a key value. For keys with characters other than `[a-zA-Z0-9_]` use `.\"a\"`. |\n| `.a == 100` | Boolean expression that returns either `true` or `false`. |\n| `.[0]` | Returns the array item at the index. |\n| `.[ .a \u003e .b ]` | Returns the array item that matches the filter expression. |\n| `==` `!=` `\u003e=` `\u003e` `\u003c=` `\u003c` | Comparison operators. |\n| `eq` `ne` | Case insensitive comparison operators. |\n| `\u0026` `\\|` | Logical operators: `.a == .b \u0026 .c == 100 \\| .d == true`. |\n| `.(func)` | Calls a function. See below. |\n\n## Functions\n\n| Function | Description |\n| --- | --- | \n| `upper` | Converts a string to uppercase. |\n| `lower` | Converts a string to lowercase. |\n| `exists` | Tells if a context exists. |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofabricio%2Fjsqr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fofabricio%2Fjsqr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofabricio%2Fjsqr/lists"}