valyala/fastjson is one of the server-side repositories TopGit tracks, currently at 2.5k stars, written primarily in Go. Fast JSON parser and validator for Go. No custom structs, no code generation, no reflection
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Fast. As usual, up to 15x faster than the standard encoding/json.
See benchmarks.
Parses arbitrary JSON without schema, reflection, struct magic and code generation
contrary to easyjson.
Provides simple API.
Outperforms jsonparser and gjson
when accessing multiple unrelated fields, since fastjson parses the input JSON only once.
Validates the parsed JSON unlike jsonparser
and gjson.
May quickly extract a part of the original JSON with Value.Get(...).MarshalTo and modify it
with Del
and Set functions.
May parse array containing values with distinct types (aka non-homogenous types).
For instance, fastjson easily parses the following JSON array [123, "foo", [456], {"k": "v"}, null].
fastjson preserves the original order of object items when calling
Object.Visit.
Known limitations
Requies extra care to work with - references to certain objects recursively
returned by Parser
must be released before the next call to Parse.
Otherwise the program may work improperly. The same applies to objects returned by Arena.
Adhere recommendations from docs.
Cannot parse JSON from io.Reader. There is Scanner
for parsing stream of JSON values from a string.
fastjson shouldn't crash or panic when parsing input strings specially crafted
by an attacker. It must return error on invalid input JSON.
fastjson requires up to sizeof(Value) * len(inputJSON) bytes of memory
for parsing inputJSON string. Limit the maximum size of the inputJSON
before parsing it in order to limit the maximum memory usage.
Performance optimization tips
Re-use Parser and Scanner
for parsing many JSONs. This reduces memory allocations overhead.
ParserPool may be useful in this case.
Prefer calling Value.Get* on the value returned from Parser
instead of calling Get* one-liners when multiple fields
must be obtained from JSON, since each Get* one-liner re-parses
the input JSON again.
Prefer calling once Value.Get
for common prefix paths and then calling Value.Get* on the returned value
for distinct suffix paths.
Prefer iterating over array returned from Value.GetArray
with a range loop instead of calling Value.Get* for each array item.
Fuzzing
Install go-fuzz & optionally the go-fuzz-corpus.
go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
Build using go-fuzz-build and run go-fuzz with an optional corpus.
stdjson-map - parse into a map[string]interface{} using encoding/json.
stdjson-struct - parse into a struct containing
a subset of fields of the parsed JSON, using encoding/json.
stdjson-empty-struct - parse into an empty struct using encoding/json.
This is the fastest possible solution for encoding/json, may be used
for json validation. See also benchmark results for json validation.
fastjson - parse using fastjson without fields access.
fastjson-get - parse using fastjson with fields access similar to stdjson-struct.
Q: There are a ton of other high-perf packages for JSON parsing in Go. Why creating yet another package?
A: Because other packages require either rigid JSON schema via struct magic
and code generation or perform poorly when multiple unrelated fields
must be obtained from the parsed JSON.
Additionally, fastjson provides nicer API.
Q: What is the main purpose for fastjson?
A: High-perf JSON parsing for RTB
and other JSON-RPC services.
Q: Why fastjson doesn't provide fast marshaling (serialization)?
A: Actually it provides some sort of marshaling - see Value.MarshalTo.
But I'd recommend using quicktemplate
for high-performance JSON marshaling :)
Q: fastjson crashes my program!
A: There is high probability of improper use.
Make sure you don't hold references to objects recursively returned by Parser / Scanner
beyond the next Parser.Parse / Scanner.Next call
if such restriction is mentioned in docs.
Make sure you don't access fastjson objects from concurrently running goroutines
if such restriction is mentioned in docs.
Build and run your program with -race flag.
Make sure the race detector detects zero races.
If your program continue crashing after fixing issues mentioned above, file a bug.
No homepage URL was recorded for valyala/fastjson in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
How active is development on valyala/fastjson?
The most recent commit recorded on valyala/fastjson was 6 months ago, based on the GitHub push timestamp. The repository has 158 forks — one of the better signals of community interest.
How many stars does valyala/fastjson have?
valyala/fastjson has 2.5k GitHub stars — refresh the page for the live number, or check github.com/valyala/fastjson. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is valyala/fastjson open source?
Yes — valyala/fastjson ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/valyala/fastjson.
What else is in the Backend space?
valyala/fastjson is tracked by TopGit under the Backend category, alongside 6 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What topics is valyala/fastjson associated with?
GitHub's repository topics for valyala/fastjson: "fast", "go", "golang", "json", "json-parser", "json-validation". TopGit's editorial category is Backend.
Where do I read more about valyala/fastjson?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/valyala/fastjson is the definitive source.
Read full README in the tab above.
Still deciding about fastjson?
One click hands the question to an AI along with this page — see what it says about fastjson.