{"id":34160653,"url":"https://github.com/go-restit/lzjson","last_synced_at":"2026-04-08T15:31:11.011Z","repository":{"id":57482909,"uuid":"51214950","full_name":"go-restit/lzjson","owner":"go-restit","description":"A flexible JSON decoding library in Golang","archived":false,"fork":false,"pushed_at":"2016-12-06T09:56:02.000Z","size":35,"stargazers_count":32,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-14T13:39:32.488Z","etag":null,"topics":["json-library","json-structure"],"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/go-restit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-06T18:20:07.000Z","updated_at":"2025-02-15T17:11:30.000Z","dependencies_parsed_at":"2022-09-26T17:50:38.074Z","dependency_job_id":null,"html_url":"https://github.com/go-restit/lzjson","commit_stats":null,"previous_names":["go-lzjson/lzjson"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/go-restit/lzjson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-restit%2Flzjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-restit%2Flzjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-restit%2Flzjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-restit%2Flzjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-restit","download_url":"https://codeload.github.com/go-restit/lzjson/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-restit%2Flzjson/sbom","scorecard":{"id":432409,"data":{"date":"2025-08-11","repo":{"name":"github.com/go-restit/lzjson","commit":"efe3c53acc682f0a1f43cecd3e3e0d535af3e73e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENCE:0","Info: FSF or OSI recognized license: MIT License: LICENCE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-19T03:41:23.851Z","repository_id":57482909,"created_at":"2025-08-19T03:41:23.851Z","updated_at":"2025-08-19T03:41:23.851Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31562685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"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-library","json-structure"],"created_at":"2025-12-15T08:37:25.999Z","updated_at":"2026-04-08T15:31:11.003Z","avatar_url":"https://github.com/go-restit.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lzjson [![GoDoc][godoc-badge]][godoc] [![Travis CI results][travis-badge]][travis] [![AppVeyor][appveyor-badge]][appveyor] [![Coverage Status][coveralls-badge]][coveralls]\n\n\n**lzjson** is a JSON decoding library aims to make you lazy.\n\nGolang default [JSON library](https://golang.org/pkg/encoding/json/) requires to\nprovide certain data structure (e.g. struct) to decode data to. It is hard to\nwrite type-inspecific code to examine JSON data structure. It is also hard to\ndetermine the abcence or prescence of data field.\n\nThis library provide flexible interface for writing generic JSON parsing code.\n\nKey features:\n\n  * zero knowledge parsing: can read and examine JSON structure without\n    pre-defining the data structure before hand.\n\n  * lazy parsing: allow you to parse only a specific node into golang data\n    structure.\n\n  * compatibility: totally compatible with the default json library\n\n[godoc]: https://godoc.org/github.com/go-restit/lzjson\n[godoc-badge]: https://godoc.org/github.com/go-restit/lzjson?status.svg\n[travis]: https://travis-ci.org/go-restit/lzjson?branch=master\n[travis-badge]: https://api.travis-ci.org/go-restit/lzjson.svg?branch=master\n[appveyor]: https://ci.appveyor.com/project/yookoala/lzjson?branch=master\n[appveyor-badge]: https://ci.appveyor.com/api/projects/status/github/go-restit/lzjson?branch=master\u0026svg=true\n[coveralls]: https://coveralls.io/github/go-restit/lzjson?branch=master\n[coveralls-badge]: https://coveralls.io/repos/github/go-restit/lzjson/badge.svg?branch=master\n\n## Example Use\n\n### Decode a JSON\n\nDecode is straight forward with any [io.Reader](https://golang.org/pkg/io/#Reader)\nimplementation (e.g.\n[http.Request.Body](https://golang.org/pkg/net/http/#Request),\n[http.Response.Body](https://golang.org/pkg/net/http/#Response),\n[strings.Reader](https://golang.org/pkg/strings/#Reader)).\n\nFor example, in a [http.HandlerFunc](https://golang.org/pkg/net/http/#HandlerFunc):\n\n```go\n\nimport (\n  \"net/http\"\n\n  \"github.com/go-restit/lzjson\"\n)\n\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n  json := lzjson.Decode(r.Body)\n  ...\n  ...\n}\n\n```\n\nOr as a client:\n\n```go\nfunc main() {\n  resp, _ := http.Get(\"http://foobarapi.com/things\")\n  json := lzjson.Decode(resp.Body)\n  ...\n  ...\n}\n```\n\n### Get a node in an object or an array\n\nYou may retrieve the JSON value of any node.\n\n```go\n// get \"foo\" in the json\nfoo := json.Get(\"foo\")\n\n// get the 10th item in foo\n// (like ordinary array, 0 is the first)\nitem10 := foo.GetN(9)\n```\n\n### Every node knows what it is\n\n```go\nbody := strings.NewReader(`\n{\n  \"string\": \"hello world\",\n  \"number\": 3.14,\n  \"bool\": true,\n  \"array\": [1, 2, 3, 5],\n  \"object\": {\"foo\": \"bar\"}\n}\n`)\njson := lzjson.Decode(body)\n\nfmt.Printf(\"%s\", json.Get(\"string\").Type()) // output \"TypeString\"\nfmt.Printf(\"%s\", json.Get(\"number\").Type()) // output \"TypeNumber\"\nfmt.Printf(\"%s\", json.Get(\"bool\").Type())   // output \"TypeBool\"\nfmt.Printf(\"%s\", json.Get(\"array\").Type())  // output \"TypeArray\"\nfmt.Printf(\"%s\", json.Get(\"object\").Type()) // output \"TypeObject\"\n```\n\n### Evaluating values a JSON node\n\nFor basic value types (string, int, bool), you may evaluate them directly.\n\n```go\ncode := json.Get(\"code\").Int()\nmessage := json.Get(\"message\").String()\n```\n\n### Partial Unmarsaling\n\nYou may decode only a child-node in a JSON structure.\n\n```go\n\ntype Item struct {\n  Name   string `json:\"name\"`\n  Weight int    `json:\"weight\"`\n}\n\nvar item Item\nitem10 := foo.GetN(9)\nitem10.Unmarshal(\u0026item)\nlog.Printf(\"item: name=%s, weight=%d\", item.Name, item.Weight)\n\n```\n\n### Chaining\n\nYou may chain `Get` and `GetN` to get somthing deep within.\n\n```go\n\nhelloIn10thBar := lzjson.Decode(r.Body).Get(\"foo\").GetN(9).Get(\"hello\")\n\n```\n\n### Looping Object or Array\n\nLooping is straight forward with `Len` and `GetKeys`.\n\n```go\nvar item Item\nfor i := 0; i\u003cfoo.Len(); i++ {\n  foo.Get(i).Unmarshal(\u0026item)\n  log.Printf(\"i=%d, value=%#v\", i, item)\n}\n\nfor _, key := range json.GetKeys() {\n  log.Printf(\"key=%#v, value=%#v\", key, json.Get(key).String())\n}\n```\n\n### Error knows their location\n\nWith chaining, it is important where exactly did any parse error happen.\n\n```go\n\nbody := strings.NewReader(`\n{\n  \"hello\": [\n    {\n      \"name\": \"world 1\"\n    },\n    {\n      \"name\": \"world 2\"\n    },\n    {\n      \"name\": \"world 3\"\n    },\n  ],\n}\n`)\njson := lzjson.Decode(body)\n\ninner := json.Get(\"hello\").GetN(2).Get(\"foo\").Get(\"bar\").GetN(0)\nif err := inner.ParseError(); err != nil {\n  fmt.Println(err.Error()) // output: \"hello[2].foo: undefined\"\n}\n\n```\n\n### Full Example\n\nPut everything above together, we can do something like this:\n\n```go\n\npackage main\n\nimport (\n  \"log\"\n  \"net/http\"\n\n  \"github.com/go-restit/lzjson\"\n)\n\ntype Thing struct {\n  ID        string    `json:\"id\"`\n  Name      string    `json:\"name\"`\n  Found     time.Time `json:\"found\"`\n  FromEarth bool      `json:\"from_earth\"`\n}\n\n/**\n * assume the API endpoints returns data:\n * {\n *   \"code\": 200,\n *   \"data\": [\n *     ...\n *   ]\n * }\n *\n * or error:\n * {\n *   \"code\": 500,\n *   \"message\": \"some error message\"\n * }\n *\n */\nfunc main() {\n  resp, err := http.Get(\"http://foobarapi.com/things\")\n  if err != nil {\n    panic(err)\n  }\n\n  // decode the json as usual, if no error\n  json := lzjson.Decode(resp.Body)\n  if code := json.Get(\"code\").Int(); code != 200 {\n    message := json.Get(\"message\").String()\n    log.Fatalf(\"error %d: \", code, message)\n  }\n\n  // get the things array\n  things := json.Get(\"data\")\n\n  // loop through the array\n  for i := 0; i\u003cthings.Len(); i++ {\n    thing := things.GetN(i)\n    if err := thing.ParseError(); err != nil {\n      log.Fatal(err.Error())\n    }\n\n    // if the thing is not from earth, unmarshal\n    // as a struct then read the details\n    if !thing.Get(\"from_earth\").Bool() {\n      var theThing Thing\n      thing.Unmarshal(\u0026theThing)\n      log.Printf(\"Alien found! %#v\", theThing)\n    }\n  }\n\n}\n\n```\n\nFor more details, please read the [documentation][godoc]\n\n\n## Contirbuting\n\nYour are welcome to contribute to this library.\n\nTo report bug, please use the [issue tracker][issue tracker].\n\nTo fix an existing bug or implement a new feature, please:\n\n1. Check the [issue tracker][issue tracker] and [pull requests][pull requests] for existing discussion.\n2. If not, please open a new issue for discussion.\n3. Write tests.\n4. Open a pull request referencing the issue.\n5. Have fun :-)\n\n[issue tracker]: https://github.com/go-restit/lzjson/issues\n[pull requests]: https://github.com/go-restit/lzjson/pulls\n\n\n## Licence\n\nThis software is licenced with the [MIT Licence] [licence].\nYou can obtain a copy of the licence in this repository.\n\n[licence]: /LICENCE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-restit%2Flzjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-restit%2Flzjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-restit%2Flzjson/lists"}