{"id":37860618,"url":"https://github.com/tada/jsonstream","last_synced_at":"2026-01-16T16:31:37.895Z","repository":{"id":57525028,"uuid":"255523274","full_name":"tada/jsonstream","owner":"tada","description":"Helper functions to enable true JSON streaming capabilities.","archived":false,"fork":false,"pushed_at":"2020-05-01T14:15:28.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-07T18:15:40.717Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tada.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":"2020-04-14T05:58:32.000Z","updated_at":"2020-05-01T14:15:31.000Z","dependencies_parsed_at":"2022-08-26T03:32:05.863Z","dependency_job_id":null,"html_url":"https://github.com/tada/jsonstream","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tada/jsonstream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tada%2Fjsonstream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tada%2Fjsonstream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tada%2Fjsonstream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tada%2Fjsonstream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tada","download_url":"https://codeload.github.com/tada/jsonstream/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tada%2Fjsonstream/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"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":"2026-01-16T16:31:37.768Z","updated_at":"2026-01-16T16:31:37.873Z","avatar_url":"https://github.com/tada.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"JSONStream provides helper functions to enable true JSON streaming capabilities.\n\n[![](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![](https://goreportcard.com/badge/github.com/tada/jsonstream)](https://goreportcard.com/report/github.com/tada/jsonstream)\n[![](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/tada/jsonstream)\n[![](https://github.com/tada/jsonstream/workflows/JSONStream%20Test/badge.svg)](https://github.com/tada/jsonstream/actions)\n[![](https://coveralls.io/repos/github/tada/jsonstream/badge.svg?service=github)](https://coveralls.io/github/tada/jsonstream)\n\n### How to get:\n```sh\ngo get github.com/tada/jsonstream\n```\n### Sample usage\n\nSince jsonstream uses the github.com/tada/catch module, all error handling is baked into the support functions. If any\nerror is encountered, it will result in a panic that is recovered in the top level functions `Marshal` and `Unmarshal`.\nCode using the support functions, like in the example below, is compact since no error propagation is needed.\n```go\npackage tst\n\nimport (\n  \"encoding/json\"\n  \"io\"\n  \"time\"\n\n  \"github.com/tada/catch/pio\"\n  \"github.com/tada/jsonstream\"\n)\n\ntype ts struct {\n  v time.Duration\n}\n\n// MarshalJSON is from the json.Marshaller interface\nfunc (t *ts) MarshalJSON() ([]byte, error) {\n  // Dispatch to the helper function\n  return jsonstream.Marshal(t)\n}\n\n// UnmarshalJSON is from the json.Marshaller interface\nfunc (t *ts) UnmarshalJSON(bs []byte) error {\n  // Dispatch to the helper function\n  return jsonstream.Unmarshal(t, bs)\n}\n\n// MarshalToJSON encode as json and stream result to the writer\nfunc (t *ts) MarshalToJSON(w io.Writer) {\n  pio.WriteByte('{', w)\n  jsonstream.WriteString(\"v\", w)\n  pio.WriteByte(':', w)\n  pio.WriteInt(int64(t.v/time.Millisecond), w)\n  pio.WriteByte('}', w)\n}\n\n// UnmarshalToJSON decodes using the given decoder\nfunc (t *ts) UnmarshalFromJSON(js jsonstream.Decoder, firstToken json.Token) {\n  jsonstream.AssertDelim(firstToken, '{')\n  for {\n    s, ok := js.ReadStringOrEnd('}')\n    if !ok {\n      break\n    }\n    if s == \"v\" {\n      t.v = time.Duration(js.ReadInt()) * time.Millisecond\n    }\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftada%2Fjsonstream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftada%2Fjsonstream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftada%2Fjsonstream/lists"}