A high-performance Go library for JSON unmarshalling that handles both known and unknown fields without data loss.
Marshmallow is a Go library for JSON unmarshalling that excels at handling mixed structured and unstructured data. It allows developers to unmarshal JSON into a typed struct while preserving unknown fields in a dynamic map, solving the problem of data loss when working with partial schemas.
Go developers working with JSON APIs, microservices, or data pipelines where input data may have both known and unknown fields.
Developers choose Marshmallow for its performance—it's up to 3x faster than alternatives for mixed data—and its simplicity, requiring no extra code to retain full JSON data while using typed structs.
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.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Benchmarks show it performs as fast as native json.Unmarshal (1845 ns/op vs. 1853 ns/op) while retaining all data, with optimizations like reflection caching.
Efficiently unmarshals JSON with both known and unknown fields into typed structs and a dynamic map simultaneously, eliminating boilerplate code for partial schemas.
Prevents data loss by returning a map with all original JSON fields alongside the typed struct, unlike standard unmarshal which drops unknown fields.
Offers options like WithSkipPopulateStruct for speed boosts and WithMode for error handling, providing fine-grained control over unmarshalling behavior.
To capture unknown nested fields, structs must implement JSONDataErrorHandler, adding boilerplate and complexity compared to flat structures.
For known fields, it allocates more memory (608 B/op) than native unmarshal (304 B/op), as per benchmarks, which might impact memory-sensitive applications.
Introduces reliance on external maintenance; while active, future breaking changes or abandonment could affect long-term projects compared to the standard library.