{"id":17124931,"url":"https://github.com/shellyln/go-small-jsonpath","last_synced_at":"2026-05-01T10:32:32.310Z","repository":{"id":65593797,"uuid":"595368238","full_name":"shellyln/go-small-jsonpath","owner":"shellyln","description":"Small, feature limited JSONPath (+dialect) implementation.","archived":false,"fork":false,"pushed_at":"2023-02-04T10:32:57.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T03:34:40.794Z","etag":null,"topics":["go","golang","golang-library","json","jsonpath","parser"],"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/shellyln.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE.md","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-01-30T23:44:08.000Z","updated_at":"2023-01-31T14:31:20.000Z","dependencies_parsed_at":"2023-02-16T19:45:26.868Z","dependency_job_id":null,"html_url":"https://github.com/shellyln/go-small-jsonpath","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"c3efd54d6bec200e21b55e40a67ea03eba2252ae"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/shellyln/go-small-jsonpath","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellyln%2Fgo-small-jsonpath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellyln%2Fgo-small-jsonpath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellyln%2Fgo-small-jsonpath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellyln%2Fgo-small-jsonpath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shellyln","download_url":"https://codeload.github.com/shellyln/go-small-jsonpath/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellyln%2Fgo-small-jsonpath/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32494270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["go","golang","golang-library","json","jsonpath","parser"],"created_at":"2024-10-14T18:43:43.115Z","updated_at":"2026-05-01T10:32:32.286Z","avatar_url":"https://github.com/shellyln.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Small JSONPath\nSmall, feature limited JSONPath (+dialect) implementation.\n\n[![Test](https://github.com/shellyln/go-small-jsonpath/actions/workflows/test.yml/badge.svg)](https://github.com/shellyln/go-small-jsonpath/actions/workflows/test.yml)\n[![release](https://img.shields.io/github/v/release/shellyln/go-small-jsonpath)](https://github.com/shellyln/go-small-jsonpath/releases)\n[![Go version](https://img.shields.io/github/go-mod/go-version/shellyln/go-small-jsonpath)](https://github.com/shellyln/go-small-jsonpath)\n\n## ✅ Features\n+ Query that returns a single value\n+ Safe query; returns zero value on failure\n+ Negative value index; index from the last element, e.g.. `foo[-1].bar`\n\n## 🛑 Unsupported features\n+ Query that returns multiple values\n+ Conditional query\n+ Wildcard\n+ Descendant node query\n+ Aggregate functions\n+ Other functions\n\n## ⭐ Dialect\n### Function\n\n#### **`first`**\n\nReturns the first item in the array.\n```js\n$.foo.(first).bar\n```\n\n#### **`last`**\n\nReturns the last item in the array.\n```js\n$.foo.(last).bar\n```\n\n#### **`length`**\n\nReturns the length of the array.\n```js\n$.foo.(length)\n```\n\n## 🚀 Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/shellyln/go-small-jsonpath/jsonpath\"\n)\n\nfunc main() {\n    json, err := jsonpath.ReadString(`{\"test\":[{\"abc\":1},{\"abc\":10}]}`)\n    if err != nil {\n        fmt.Printf(\"ReadString: error = %v\\n\", err)\n        return\n    }\n\n    path, err := jsonpath.Compile(`$.test[1].abc`)\n    if err != nil {\n        fmt.Printf(\"Compile: error = %v\\n\", err)\n        return\n    }\n\n    v, err := path.Query(json) // returns nil, float64, string, []any, map[string]any\n    if err != nil {\n        fmt.Printf(\"Query: error = %v\\n\", err)\n        return\n    }\n    fmt.Printf(\"Query: %v\\n\", v) // float64(10)\n\n    vn := path.QueryAsNumberOrZero(json) // returns zero value on failure\n    fmt.Printf(\"QueryAsNumberOrZero: %v\\n\", vn) // float64(10)\n\n    vs := path.QueryAsStringOrZero(json) // returns zero value on failure\n    fmt.Printf(\"QueryAsStringOrZero: %v\\n\", vs) // \"\" (zero value)\n}\n```\n\n## 🪄 Query examples\n\nData:\n```json\n{\n    \"foo\": [11, 12, 13],\n    \"bar\": \"abcdefg\",\n    \"baz\": -9876,\n    \"qux\": {\n        \"quux\": null\n    }\n}\n```\n\nQueries:\n```go\n\u003e $.foo[0]\n11\n\n\u003e $['foo'][1]\n12\n\n\u003e $['foo'][3]\nerror (index out of range)\n\n\u003e $['foo'][-1]\n13\n\n\u003e $[\"foo\"].(length)\n3\n\n\u003e $[\"foo\"].(first)\n11\n\n\u003e $[\"foo\"].(last)\n13\n\n\u003e $.bar\n\"abcdefg\"\n\n\u003e $.bar.(length)\nerror (unsupported function operand)\n\n\u003e $.qux.quux\nnil\n\n\u003e $['qux'].quux\nnil\n\n\u003e $['qux'][\"quux\"]\nnil\n\n\u003e $.foo\nmap[string]any{...}\n\n\u003e $.qux\n[]any{...}\n```\n\n## ⚖️ License\n\nMIT  \nCopyright (c) 2023 Shellyl_N and Authors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshellyln%2Fgo-small-jsonpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshellyln%2Fgo-small-jsonpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshellyln%2Fgo-small-jsonpath/lists"}