Data Serialization in Go
Data Serialization in Go
The Complete Guide to JSON and Other Serialization Formats in Go
About the Book
Strict types, a lack of object-oriented features, and no generics are just some of the limitations that apply to data serialization in Go. Proper and efficient data serialization can be daunting even for the most experienced Go developer. For the newcomer, it's often overwhelming and infuriating.
This book grew out of several years of experience building and maintaining Kivik (https://kivik.io/), the popular CouchDB driver/SDK for Go. In working with CouchDB, which relies heavily on sophisticated manipulation of JSON documents, the author developed several novel techniques and approaches to solve common problems encountered in data serialization.
This work-in-progress book consolidates all of the author's knowledge, research, and tips and tricks on the subject, in a single place.
Table of Contents
- Preface
- Contents
-
Introduction (WIP)
-
What is Data Serialization
- Subtleties
- Serialization is key
- History (TODO)
-
- When the decision has been made for you
- Strengths
- Weaknesses
- Strengths
- Weaknesses
- Strengths
- Weaknesses
- BSON (TODO)
- MessagePack (TODO)
- Smile (TODO)
- Ion (TODO)
- CBOR (TODO)
- XML (TODO)
- Protobuf (TODO)
- CSV (TODO)
- Custom \& proprietary formats (TODO)
-
What is Data Serialization
-
Getting Started with JSON (TODO)
- The encoding/json Package (TODO)
- Marshaling JSON (TODO)
- Unmarshaling JSON (TODO)
- Creating a Custom Marshaler (TODO)
- Creating a Custom Unmarshaler (TODO)
- Relationship to the encoding Package (TODO)
- json.Encoder Options (TODO)
- json.Decoder Options (TODO)
- Streaming Limitations (TODO)
- Best Practices for Readable Serialization Code (TODO)
- Using a Linter (TODO)
-
Data Serialization Toolbox (WIP)
- Pointer vs Value Receivers (TODO)
- The Self-Referencing (Un)Marshaler
- Configurable Marshalers (TODO)
- Validation of input and output (TODO)
- Embedding fields (TODO)
- Internal types (TODO)
- Combining JSON Objects
-
Working with Simple Types (TODO)
- Standard Types (TODO)
- Numbers (TODO)
-
Wrapping Existing Types
- Regular Expressions
- time.Time
- Extending an Embedded Marshaler
- Combining Multiple Structs Into a Single JSON Object
- A Single JSON Object to Multiple Go Structs
-
Streaming JSON Output (WIP)
- Producing an io.Reader from an Object
- Providing a net/http.Request.GetBody Function
- Optimizing for Memory Usage (TODO)
- json.NewEncoder For Shorter Code (TODO)
- Optimizing for Memory Usage (TODO)
- JSON Tokenizer (TODO)
-
Working with YAML (TODO)
- What is YAML (TODO)
- When to use YAML (TODO)
- Converting JSON to YAML (TODO)
- Converting YAML to JSON (TODO)
- What is BSON (TODO)
- When to use BSON (TODO)
- Converting JSON to BSON (TODO)
- Converting BSON to JSON (TODO)
- What is MessagePack (TODO)
- When to use MessagePack (TODO)
- Converting JSON to MessagePack (TODO)
- Converting MessagePack to JSON (TODO)
- What is CBOR (TODO)
- When to use CBOR (TODO)
- Converting JSON to CBOR (TODO)
- Converting CBOR to JSON (TODO)
- What is TOML (TODO)
- When to use TOML (TODO)
- Converting JSON to TOML (TODO)
- Converting TOML to JSON (TODO)
- What is XML (TODO)
- When to use XML (TODO)
- What is ProtoBuf (TODO)
- When to use ProtoBuf (TODO)
- Converting to ProtoBuf (TODO)
- Converting from ProtoBuf (TODO)
- INI (TODO)
- Smile (TODO)
- Comma-Separated Values (CSV) (TODO)
- Custom \& Proprietary Formats (TODO)
-
Related Formats and Concepts (TODO)
- Binary-to-Text: URL Encoding, Base64, Etc (TODO)
- VarInt (TODO)
- MIME (TODO)
- Data Compression (TODO)
-
Third-Party Libraries (TODO)
- github.com/valyala/fastjson (TODO)
- github.com/json-iterator/go (TODO)
- ffjson (TODO)
- Others (TODO)
- Alphabetical Index
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them