marshmallow
Marshmallow provides a flexible and performant JSON unmarshalling in Go. It specializes in dealing with unstructured struct - when some fields are known and some aren't, with zero performance overhead nor extra coding needed. (by PerimeterX)
fastjson
Fast JSON parser and validator for Go. No custom structs, no code generation, no reflection (by valyala)
Our great sponsors
marshmallow | fastjson | |
---|---|---|
5 | 18 | |
354 | 2,162 | |
3.7% | - | |
3.2 | 0.0 | |
10 months ago | 2 months ago | |
Go | Go | |
MIT License | MIT License |
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
marshmallow
Posts with mentions or reviews of marshmallow.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2022-11-27.
-
Why Go is the Future of Backend Development
Also, JSON marshaling and unmarshaling may also be an issue. C/C++ are quite varied - I suppose they either use the fields of the JSON as is, or use some ugly-ass macros (u/xkcd-Hyphen-bot, do your thing. It actually fits here), but Go entries would probably used the standard way to do this in Go - the encoding/json package - which needs to read and parse struct field tags at runtime. Does it at least cache the parsed definitions? From the complaints I see about it, I doubt it. Also, there seems to be Marshmallow that can do caching (among other optimizations) and greatly outperforms the build in one. I guess that means the standard library implementation doesn't do it? That would explain why the TechEmpower benchmark entries are so slow - I don't think they use Marshmallow. Marshmallow has less than 300 starts on GitHub, which is far less than what you would expect it to have if it was commonly used.
-
JSON array with two different json objects
I believe this was one of the reasons for marshmallow being written: https://github.com/PerimeterX/marshmallow The idea to partially unmarshal, inspect the type field, and then make a second pass.
-
Is there a way to parse unstructured data?
Try out https://github.com/PerimeterX/marshmallow
-
Help with calling function dynamically based on name
I think this is what marshmallow was made for: https://github.com/PerimeterX/marshmallow
-
Marshmallow - a JSON unmarshalling library for flexible use cases like some known and some unknown fields, or prevention of data loss
Marshmallow is used internally at PerimeterX for some time, and we've recently decided to open-source it and share a blog post about how it helped us trim 70% of our JSON parsing costs in production.
fastjson
Posts with mentions or reviews of fastjson.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2023-06-29.
-
What's the best way to unmarshall this nested JSON?
I’ve used fastjson when unmarshalling to Structs is inconvenient. https://github.com/valyala/fastjson
-
Object-oriented JSON in Go
Interesting approach, even though reflection support is supposed to be landing soon, this would be really really useful when using TinyGo. (Fro example, writing web backend serverless functions with Fermyon’s Spin framework for WASM that needs to return JSON). Do you have any benchmarks on how it performs vs stdlib’s encoding/json and/or something like fastjson?
- Best approach for a monolithic web app?
-
High-performance JSON parsing in Go
It relies heavily on bytes.IndexOf for which Go provides SIMD optimizations transparently. However, it has some correctness issues when parsing malformed json that might need to be addressed. Generally it is recommended to be used with trusted json documents for internal services and may require further testing before being used to parse arbitrary json documents.
-
3 Ways I Keep My Rest APIs endpoints down to 4-6 lines and eliminate boilerplate. What are yours?
Try fastjson library. It allows you to grab deeply nested json objects without marshalling the entire json.
- Any way to convert unknown/dynamic json to generic object structure
- json.Decoder, ways to skip first tokens.
-
Golang, GraphQL y Postgress
Como herramientas te recomiendo: FastJson https://github.com/valyala/fastjson : Si necesitas leer jsons Testify https://github.com/stretchr/testify : Para mockear y testear
-
Ad hoc JSON parsing
In Go if I need to extract just a few fields from a large JSON document it's hard to beat https://github.com/valyala/fastjson
-
TinyGo Reflection?
Another option is to use what I like to call "Lazy" decoders, like https://github.com/valyala/fastjson which will work with TinyGo, but doesn't have the same type of API as the standard lib (or alternatives) in terms of Marshaling and Unmarshalling. Instead you "Parse" a JSON object, and use Getters to access the types you want.
What are some alternatives?
When comparing marshmallow and fastjson you can also consider the following projects:
jsondiff - Compute the diff between two JSON documents as a series of RFC6902 (JSON Patch) operations
easyjson - Fast JSON serializer for golang.
jettison - Highly configurable, fast JSON encoder for Go
sonic - A blazingly fast JSON serializing & deserializing library
jsonic - All you need with JSON
jsonparser - One of the fastest alternative JSON parser for Go that does not require schema
mapslice-json - Go MapSlice for ordered marshal/ unmarshal of maps in JSON
ej - Write and read JSON from different sources in one line
gjo - Small utility to create JSON objects
go-parameters - :blue_book: Easily parse incoming parameters and values from an HTTP request