{"id":21391616,"url":"https://github.com/multiprocessio/go-json","last_synced_at":"2025-07-13T18:30:38.647Z","repository":{"id":41851195,"uuid":"465865270","full_name":"multiprocessio/go-json","owner":"multiprocessio","description":"Fast Go JSON encoder for large arrays of objects","archived":false,"fork":false,"pushed_at":"2022-04-26T13:59:31.000Z","size":15,"stargazers_count":47,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-06-18T21:33:34.194Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/multiprocessio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-03T19:56:45.000Z","updated_at":"2024-05-15T14:24:02.000Z","dependencies_parsed_at":"2022-09-25T05:01:12.782Z","dependency_job_id":null,"html_url":"https://github.com/multiprocessio/go-json","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiprocessio%2Fgo-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiprocessio%2Fgo-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiprocessio%2Fgo-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiprocessio%2Fgo-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/multiprocessio","download_url":"https://codeload.github.com/multiprocessio/go-json/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225906286,"owners_count":17543130,"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":[],"created_at":"2024-11-22T13:35:05.681Z","updated_at":"2024-11-22T13:35:06.282Z","avatar_url":"https://github.com/multiprocessio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fast JSON encoding\n\nSee [this blog\npost](https://datastation.multiprocess.io/blog/2022-03-03-improving-go-json-encoding-performance-for-large-arrays-of-objects.html)\nfor the rational and benchmarks.\n\ntldr; when writing an array of objects this library can speed things\nup. Especially as the number of objects in the array and the number of\ncolumns in the object grow.\n\n## Writing a whole array at once\n\nIf you have a whole large array at once, there is a helper function\nfor writing it all out at once.\n\n```go\npackage main\n\nimport (\n\t\"os\"\n\t\n\t\"github.com/multiprocessio/go-json\"\n)\n\nfunc main() {\n\t// Uses stdlib's encoding/json\n\tdata := []interface{}{\n\t\tmap[string]interface{}{\"a\": 1, \"b\": 2},\n\t\tmap[string]interface{}{\"a\": 5, \"c\": 3, \"d\": \"xyz\"},\n\t}\n\n\tout := os.Stdout // Can be any io.Writer\n\t\n\terr := jsonutil.Encode(out, data)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\n## Streaming encoding an array\n\nIf you are streaming data, there is also support for stream encoding\nwith this library:\n\n\n```go\npackage main\n\nimport (\n\t\"os\"\n\t\n\t\"github.com/multiprocessio/go-json\"\n)\n\nfunc main() {\n\t// Uses stdlib's encoding/json\n\tdata := []interface{}{\n\t\tmap[string]interface{}{\"a\": 1, \"b\": 2},\n\t\tmap[string]interface{}{\"a\": 5, \"c\": 3, \"d\": \"xyz\"},\n\t}\n\n\tout := os.Stdout // Can be any io.Writer\n\n\tencoder := jsonutil.NewStreamEncoder(out, true)\n\tfor _, row := range data {\n\t\terr := encoder.EncodeRow(row)\n\t\tif err != nil{\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n\terr := encoder.Close()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultiprocessio%2Fgo-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmultiprocessio%2Fgo-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultiprocessio%2Fgo-json/lists"}