{"id":13413279,"url":"https://github.com/ohler55/ojg","last_synced_at":"2025-05-13T17:09:17.988Z","repository":{"id":37988036,"uuid":"255132844","full_name":"ohler55/ojg","owner":"ohler55","description":"Optimized JSON for Go","archived":false,"fork":false,"pushed_at":"2025-05-13T00:15:45.000Z","size":1388,"stargazers_count":888,"open_issues_count":1,"forks_count":50,"subscribers_count":9,"default_branch":"develop","last_synced_at":"2025-05-13T01:20:30.773Z","etag":null,"topics":["fast","golang","json","jsonpath","parser"],"latest_commit_sha":null,"homepage":null,"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/ohler55.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"github":["ohler55"]}},"created_at":"2020-04-12T17:17:31.000Z","updated_at":"2025-05-13T00:05:27.000Z","dependencies_parsed_at":"2023-10-14T22:09:09.398Z","dependency_job_id":"997952b0-0201-4bc8-915c-05a5198adff4","html_url":"https://github.com/ohler55/ojg","commit_stats":{"total_commits":349,"total_committers":9,"mean_commits":38.77777777777778,"dds":"0.025787965616045794","last_synced_commit":"a3e5bee1a7bc0004737baf6837b6246479acb2ed"},"previous_names":[],"tags_count":91,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohler55%2Fojg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohler55%2Fojg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohler55%2Fojg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohler55%2Fojg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ohler55","download_url":"https://codeload.github.com/ohler55/ojg/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990468,"owners_count":21995774,"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":["fast","golang","json","jsonpath","parser"],"created_at":"2024-07-30T20:01:36.717Z","updated_at":"2025-05-13T17:09:12.963Z","avatar_url":"https://github.com/ohler55.png","language":"Go","funding_links":["https://github.com/sponsors/ohler55"],"categories":["JSON","Go","Libraries","Relational Databases"],"sub_categories":["Search and Analytic Databases","检索及分析资料库","Advanced Console UIs"],"readme":"# [![{}j](assets/ojg_comet.svg)](https://github.com/ohler55/ojg)\n\n[![Build Status](https://github.com/ohler55/ojg/actions/workflows/CI.yml/badge.svg)](https://github.com/ohler55/ojg/actions)\n[![Go Report Card](https://goreportcard.com/badge/github.com/ohler55/ojg)](https://goreportcard.com/report/github.com/ohler55/ojg)\n![](assets/coverage-badge.svg)\n\nOptimized JSON for Go is a high performance parser with a variety of\nadditional JSON tools. OjG is optimized to processing huge data sets\nwhere data does not necessarily conform to a fixed structure.\n\n## Features\n\n - Fast JSON parser. Check out the cmd/benchmarks app in this repo.\n - Full JSONPath implemenation that operates on simple types as well as structs.\n - Generic types. Not the proposed golang generics but type safe JSON elements.\n - Fast JSON validator (7 times faster with io.Reader).\n - Fast JSON writer with a sort option (4 times faster).\n - JSON builder from JSON sources using a simple assembly plan.\n - Simple data builders using a push and pop approach.\n - Object encoding and decoding using an approach similar to that used with Oj for Ruby.\n - [Simple Encoding Notation](sen.md), a lazy way to write JSON omitting commas and quotes.\n\n## Using\n\nA basic Parse:\n\n```golang\n    obj, err := oj.ParseString(`{\n        \"a\":[\n            {\"x\":1,\"y\":2,\"z\":3},\n            {\"x\":2,\"y\":4,\"z\":6}\n        ]\n    }`)\n```\n\nUsing JSONPath expressions:\n\n```golang\n    x, err := jp.ParseString(\"a[?(@.x \u003e 1)].y\")\n    ys := x.Get(obj)\n    // returns [4]\n```\n\nThe **oj** command (cmd/oj) uses JSON path for filtering and\nextracting JSON elements. It also includes sorting, reformatting, and\ncolorizing options.\n\n```\n$ oj -m \"(@.name == 'Pete')\" myfile.json\n\n```\n\nMore complete examples are available in the go docs for most\nfunctions. The example for [Unmarshalling\ninterfaces](oj/example_interface_test.go) demonstrates a feature that\nallows interfaces to be marshalled and unmarshalled.\n\n## Installation\n```\ngo get github.com/ohler55/ojg\ngo get github.com/ohler55/ojg/cmd/oj\n\n```\n\nor just import in your `.go` files.\n\n```\nimport (\n    \"github.com/ohler55/ojg/alt\"\n    \"github.com/ohler55/ojg/asm\"\n    \"github.com/ohler55/ojg/gen\"\n    \"github.com/ohler55/ojg/jp\"\n    \"github.com/ohler55/ojg/oj\"\n    \"github.com/ohler55/ojg/sen\"\n)\n```\n\nTo build and install the `oj` application:\n\n```\ngo install ./...\n```\n\nThe `oj` application can be installed with brew.\n\n```\nbrew install oj\n```\n\n## Benchmarks\n\nHigher numbers (longer bars) are better.\n\n```\nParse string/[]byte\n       json.Unmarshal           55916 ns/op    17776 B/op    334 allocs/op\n         oj.Parse               39570 ns/op    18488 B/op    429 allocs/op\n   oj-reuse.Parse               17881 ns/op     5691 B/op    364 allocs/op\n\n   oj-reuse.Parse        █████████████████████▉ 3.13\n         oj.Parse        █████████▉ 1.41\n       json.Unmarshal    ▓▓▓▓▓▓▓ 1.00\n\nParse io.Reader\n       json.Decode              63029 ns/op    32449 B/op    344 allocs/op\n         oj.ParseReader         34289 ns/op    22583 B/op    430 allocs/op\n   oj-reuse.ParseReader         25094 ns/op     9788 B/op    365 allocs/op\n         oj.TokenizeLoad        13610 ns/op     6072 B/op    157 allocs/op\n\n         oj.TokenizeLoad ████████████████████████████████▍ 4.63\n   oj-reuse.ParseReader  █████████████████▌ 2.51\n         oj.ParseReader  ████████████▊ 1.84\n       json.Decode       ▓▓▓▓▓▓▓ 1.00\n\nto JSON with indentation\n       json.Marshal             78762 ns/op    26978 B/op    352 allocs/op\n         oj.JSON                 7662 ns/op        0 B/op      0 allocs/op\n        sen.Bytes                9053 ns/op        0 B/op      0 allocs/op\n\n         oj.JSON         ███████████████████████████████████████████████████████████████████████▉ 10.28\n        sen.Bytes        ████████████████████████████████████████████████████████████▉ 8.70\n       json.Marshal      ▓▓▓▓▓▓▓ 1.00\n```\n\nSee [all benchmarks](benchmarks.md)\n\n[Compare Go JSON parsers](https://github.com/ohler55/compare-go-json)\n\n## Releases\n\nSee [CHANGELOG.md](CHANGELOG.md)\n\n## Links\n\n- *Documentation*: [https://pkg.go.dev/github.com/ohler55/ojg](https://pkg.go.dev/github.com/ohler55/ojg)\n\n- *GitHub* *repo*: https://github.com/ohler55/ojg\n\n- *JSONPath* draft specification: https://datatracker.ietf.org/doc/draft-ietf-jsonpath-base\n\n- *JSONPath Comparisons*: https://cburgmer.github.io/json-path-comparison\n\n- *Go Report Card*: https://goreportcard.com/report/github.com/ohler55/ojg\n\n#### Links of Interest\n\n - *Oj, a Ruby JSON parser*: http://www.ohler.com/oj/doc/index.html also at https://github.com/ohler55/oj\n\n - *OjC, a C JSON parser*: http://www.ohler.com/ojc/doc/index.html also at https://github.com/ohler55/ojc\n\n - *Fast XML parser and marshaller on GitHub*: https://github.com/ohler55/ox\n\n - *Agoo, a high performance Ruby web server supporting GraphQL on GitHub*: https://github.com/ohler55/agoo\n\n - *Agoo-C, a high performance C web server supporting GraphQL on GitHub*: https://github.com/ohler55/agoo-c\n\n#### Contributing\n\n+ Provide a Pull Request off the `develop` branch.\n+ Report a bug\n+ Suggest an idea\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohler55%2Fojg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fohler55%2Fojg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohler55%2Fojg/lists"}