{"id":21331568,"url":"https://github.com/lukechampine/mjson","last_synced_at":"2026-05-14T21:31:16.026Z","repository":{"id":57551157,"uuid":"82607154","full_name":"lukechampine/mjson","owner":"lukechampine","description":"Modify JSON super fast","archived":false,"fork":false,"pushed_at":"2017-02-26T22:03:07.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T07:34:12.765Z","etag":null,"topics":["json"],"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/lukechampine.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":"2017-02-20T22:01:18.000Z","updated_at":"2019-03-13T03:22:52.000Z","dependencies_parsed_at":"2022-09-26T18:41:17.913Z","dependency_job_id":null,"html_url":"https://github.com/lukechampine/mjson","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/lukechampine%2Fmjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechampine%2Fmjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechampine%2Fmjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechampine%2Fmjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukechampine","download_url":"https://codeload.github.com/lukechampine/mjson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243809849,"owners_count":20351407,"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":["json"],"created_at":"2024-11-21T22:42:30.673Z","updated_at":"2025-10-17T01:34:54.257Z","avatar_url":"https://github.com/lukechampine.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"mjson\n-----\n\n[![GoDoc](https://godoc.org/github.com/lukechampine/mjson?status.svg)](https://godoc.org/github.com/lukechampine/mjson)\n[![Go Report Card](http://goreportcard.com/badge/github.com/lukechampine/mjson)](https://goreportcard.com/report/github.com/lukechampine/mjson)\n\n```\ngo get github.com/lukechampine/mjson\n```\n\n`mjson` sets values in JSON super fast. It is comparable to [SJSON](https://github.com/tidwall/sjson), but\nwith some key differences. It was created to support the [`jj`](https://github.com/lukechampine/jj) transaction journal.\n\nUnlike SJSON, `mjson` does not support deletion, creating nested objects,\nescaping the `.` character in paths, or the special `-1` index. However, it\ndoes support appending to `null` as though it were `[]`, and does not require\nthe special `:` syntax for integer object keys. Appending to an array is still\npossible as well, using the length of the array as an index. This is safer\nthan using `-1` because setting an explicit index is an idempotent operation,\nwhereas `-1` is context-sensitive.\n\n\n## Examples ##\n\nSet an existing object key:\n```go\njson := mjson.Set(`{\"name\":{\"last\":\"Anderson\"}}`, \"name.last\", \"Smith\")\n// {\"name\":{\"last\":\"Smith\"}}\n```\n\nAdd a new object key:\n```go\njson := mjson.Set(`{\"name\":{\"last\":\"Anderson\"}}`, \"name.first\", \"Sara\")\n// {\"name\":{\"first\":\"Sara\",\"last\":\"Anderson\"}}\n```\n\nSet an existing array value:\n```go\njson := mjson.Set(`{\"friends\":[\"Andy\",\"Carol\"]}`, \"friends.1\", \"Sara\")\n// {\"friends\":[\"Andy\",\"Sara\"]\n```\n\nAppend a new array value:\n```go\njson := mjson.Set(`{\"friends\":[\"Andy\",\"Carol\"]}`, \"friends.2\", \"Sara\")\n// {\"friends\":[\"Andy\",\"Carol\",\"Sara\"]\n```\n\n\n## Benchmarks ##\n\n`mjson` runs a teeny bit faster than SJSON:\n\n```\nBenchmark_Set-4                   \t 3000000\t       556 ns/op\t     405 B/op\t       2 allocs/op\nBenchmark_SetInPlace-4            \t 3000000\t       448 ns/op\t      21 B/op\t       2 allocs/op\nBenchmark_SetRawInPlace-4         \t 3000000\t       346 ns/op\t       0 B/op\t       0 allocs/op\nBenchmark_SJSON_Set-4             \t 3000000\t       694 ns/op\t     576 B/op\t       2 allocs/op\nBenchmark_SJSON_SetInPlace-4      \t 3000000\t       564 ns/op\t      74 B/op\t       1 allocs/op\nBenchmark_SJSON_SetRawInPlace-4   \t 3000000\t       426 ns/op\t       0 B/op\t       0 allocs/op\n```\n\nHowever, to get this speed with SJSON you must set the `Optimistic` flag.\nOtherwise its performance drops considerably:\n\n```\nBenchmark_SJSON_SetNoFlag-4        \t 3000000\t      1861 ns/op\t    1178 B/op\t       5 allocs/op\n```\n\nYou should use whichever API you prefer, though.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukechampine%2Fmjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukechampine%2Fmjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukechampine%2Fmjson/lists"}