{"id":13413274,"url":"https://github.com/zerosnake0/jzon","last_synced_at":"2026-01-27T13:41:17.734Z","repository":{"id":51446271,"uuid":"221193607","full_name":"zerosnake0/jzon","owner":"zerosnake0","description":"A golang json library inspired by jsoniter","archived":false,"fork":false,"pushed_at":"2024-10-30T04:17:43.000Z","size":431,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-15T01:51:35.795Z","etag":null,"topics":["decoder","encoder","golang","iterator","json","marshaler","streamer","unmarshaller"],"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/zerosnake0.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-11-12T10:42:41.000Z","updated_at":"2024-07-22T16:18:21.000Z","dependencies_parsed_at":"2024-01-08T15:34:40.163Z","dependency_job_id":null,"html_url":"https://github.com/zerosnake0/jzon","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/zerosnake0/jzon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerosnake0%2Fjzon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerosnake0%2Fjzon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerosnake0%2Fjzon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerosnake0%2Fjzon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zerosnake0","download_url":"https://codeload.github.com/zerosnake0/jzon/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerosnake0%2Fjzon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28813983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"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":["decoder","encoder","golang","iterator","json","marshaler","streamer","unmarshaller"],"created_at":"2024-07-30T20:01:36.623Z","updated_at":"2026-01-27T13:41:17.700Z","avatar_url":"https://github.com/zerosnake0.png","language":"Go","funding_links":[],"categories":["JSON","Relational Databases"],"sub_categories":["检索及分析资料库","Search and Analytic Databases","Advanced Console UIs","SQL 查询语句构建库"],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/zerosnake0/jzon)](https://goreportcard.com/report/github.com/zerosnake0/jzon)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/zerosnake0/jzon)](https://pkg.go.dev/github.com/zerosnake0/jzon)\n[![Github Workflow](https://github.com/zerosnake0/jzon/workflows/Test/badge.svg)](https://github.com/zerosnake0/jzon/actions?query=workflow%3ATest)\n[![Build Status](https://travis-ci.org/zerosnake0/jzon.svg?branch=master)](https://travis-ci.org/zerosnake0/jzon)\n[![codecov](https://codecov.io/gh/zerosnake0/jzon/branch/master/graph/badge.svg)](https://codecov.io/gh/zerosnake0/jzon)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n\n# jzon\n\nA high performance json library for Golang\n\n## Why another jsoniter?\n\nThe code I write here is very similar to [github.com/json-iterator/go](https://github.com/json-iterator/go),\nso you may ask why reinvent the wheel.\n\nFor sure that I benefit a lot from the `jsoniter` library, but i found some inconvenience for me to use it\nin some condition, for example:\n\n- the iterator methods ReadString accepts null, there is no method which accepts exactly string.\n  I have to do some extra check before calling.\n- some behavior is not compatible with the standard library.\n- I want a chained streamer\n\nOn the other hand, I also want to learn how the `jsoniter` works, so there is this repo.\n\n## What's different from jsoniter?\n\nHere are some of the differences:\n\n- the iterator methods accept the exact type, for example ReadString accepts only string, not null\n- the behavior is almost the same as the standard library (when an error returns, the behavior may differ\n  from the standard library)\n- the error of the iterator is returned instead of being saved inside iterator\n- the decoder/encoder interface has additional options, like struct tag options\n\nSome features of `jsoniter` are not implemented, and may be not implemented in the future neither.\nI choose only the ones I need to implement.\n\n## Compatibility with standard library\n\nI tried implemented a version which is completely compatible with the standard library:\n\nhttps://github.com/zerosnake0/jzon/tree/reflect\n\nThe benchmark shows that it's much faster than the standard library.\nHowever it is still much slower than the current version,\nwhich cannot be exactly the same as standard library (at least in my POV).\n\nThe major incompatibility is about the two following interfaces:\n- `json.Marshaler`\n- `encoding.TextMarshaler`\n\nThe method on pointer receiver may be called with an unaddressable value,\nfor example:\n\n```go\ntype field struct {}\n\nfunc (*field) MarshalJSON() ([]byte, error)\n\ntype st struct {\n    F field\n}\n\njson.Marshal(st{}) // will not call field.MarshalJSON\njzon.Marshal(st{}) // will call field.MarshalJSON\n```\n\nSo the user should be care when marshaling a value when method on\npointer receiver is involved\n\nYou can check the tests for more detailed info about the difference\n\n## How to use\n\n### Standard library like\n\n```go\nimport \"github.com/zerosnake0/jzon\"\n\n// Unmarshal\nerr := jzon.Unmarshal(b, \u0026data)\n\n// Marshal\nb, err := jzon.Marshal(\u0026data)\n\n// Decoder\ndec := jzon.NewDecoder(reader)\ndefer dec.Release()\nerr := dec.Decode(\u0026data)\n\n// Encoder\nenc := jzon.NewEncoder(writer)\ndefer enc.Release()\nerr := enc.Encode(\u0026data)\n```\n\n### Iterator\n\n```go\niter := jzon.NewIterator()\ndefer iter.Release()\niter.Reset(b)\njzon.ReadVal(\u0026data)\n```\n\n### Streamer\n\n```go\nvar w io.Writer\n\nstreamer := jzon.NewStreamer()\ndefer streamer.Release()\nstreamer.Reset(w)\nstreamer.Value(\u0026data)\nstreamer.Flush()\n```\n\n### Custom Decoder\n\nsee `decoder_test.go`\n\n```go\ntype testIntDecoder struct{}\n\nfunc (*testIntDecoder) Decode(ptr unsafe.Pointer, it *Iterator, opts *DecOpts) error {\n    ...\n}\n\ndec := NewDecoderConfig(\u0026DecoderOption{\n    ValDecoders: map[reflect.Type]ValDecoder{\n        reflect.TypeOf(int(0)): (*testIntDecoder)(nil),\n    },\n    CaseSensitive: true,\n})\n\n// standard library like\nerr := dec.Unmarshal(b, \u0026data)\n\n// iterator\niter := dec.NewIterator()\ndefer iter.Release()\n```\n\n### Custom Encoder\n\nsee `encoder_test.go`\n\n```go\ntype testIntEncoder struct{}\n\nfunc (*testIntEncoder) IsEmpty(ptr unsafe.Pointer) bool {\n    ...\n}\n\nfunc (*testIntEncoder) Encode(ptr unsafe.Pointer, s *Streamer, opts *EncOpts) {\n    ...\n}\n\nenc := NewEncoderConfig(\u0026EncoderOption{\n    ValEncoders: map[reflect.Type]ValEncoder{\n        reflect.TypeOf(int(0)): (*testIntEncoder)(nil),\n    },\n})\n\n// standard library like\nb, err := enc.Marshal(\u0026data)\n\n// streamer\nstreamer := enc.NewStreamer()\ndefer streamer.Release()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerosnake0%2Fjzon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzerosnake0%2Fjzon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerosnake0%2Fjzon/lists"}