Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Go
  3. marshmallow

marshmallow

MITGov1.1.5

A high-performance Go library for JSON unmarshalling that handles both known and unknown fields without data loss.

GitHubGitHub
391 stars12 forks0 contributors

What is marshmallow?

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.

Target Audience

Go developers working with JSON APIs, microservices, or data pipelines where input data may have both known and unknown fields.

Value Proposition

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.

Overview

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.

Use Cases

Best For

  • Unmarshalling JSON with partially known schemas
  • Building APIs that need to preserve all incoming JSON fields
  • Processing configuration files with optional or dynamic fields
  • Implementing data validation with access to raw input
  • Optimizing performance in JSON-heavy Go applications
  • Handling webhook payloads with variable structures

Not Ideal For

  • Projects where the entire JSON schema is static and known upfront, as standard json.Unmarshal suffices
  • Applications requiring advanced JSON features like schema validation, custom unmarshalers, or streaming parsing
  • Systems with strict zero-dependency policies that prefer using only the Go standard library

Pros & Cons

Pros

Near-Native Performance

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.

Mixed Data Handling

Efficiently unmarshals JSON with both known and unknown fields into typed structs and a dynamic map simultaneously, eliminating boilerplate code for partial schemas.

Full Data Retention

Prevents data loss by returning a map with all original JSON fields alongside the typed struct, unlike standard unmarshal which drops unknown fields.

Flexible Configuration

Offers options like WithSkipPopulateStruct for speed boosts and WithMode for error handling, providing fine-grained control over unmarshalling behavior.

Cons

Nested Field Complexity

To capture unknown nested fields, structs must implement JSONDataErrorHandler, adding boilerplate and complexity compared to flat structures.

Memory Overhead

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.

Third-Party Dependency

Introduces reliance on external maintenance; while active, future breaking changes or abandonment could affect long-term projects compared to the standard library.

Frequently Asked Questions

Quick Stats

Stars391
Forks12
Contributors0
Open Issues2
Last commit3 years ago
CreatedSince 2022

Tags

#unstructured-data#go-library#structured-data#golang#serialization#data-processing#json#go#performance

Built With

G
Go

Included in

Go169.1k
Auto-fetched 9 hours ago

Related Projects

GJSONGJSON

Get JSON values quickly - JSON parser for Go

Stars15,560
Forks913
Last commit11 days ago
gabsgabs

For parsing, creating and editing unknown or dynamic JSON in Go

Stars3,526
Forks200
Last commit2 years ago
SJSONSJSON

Set JSON values very quickly in Go

Stars2,738
Forks187
Last commit3 months ago
gojsongojson

Automatically generate Go (golang) struct definitions from example JSON

Stars2,689
Forks205
Last commit5 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub