Pocket Gophers

JSON Packages

2017-05-08

The standard package for dealing with JSON data, encoding/json, was designed as a general purpose tool. As such, it may not be the best tool for your use case.

If you have specific requirements or a specialized used case, one of the other packages that is available may be better suited.

github.com/Jeffail/gabs

GoDoc Go project version Report card License MIT

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

Using encoding/json with dynamic json means working with map[string]interface{}. This generally results in an explosion of code to deal with the mismatch between the dynamic typing of JSON and the static typing of Go. Gobs wraps encoding/json and map[string]interface{} with an API that will reduce the amount of code you need to write.

github.com/a8m/djson

GoDoc Go project version Report card License MIT

Fast Go decoder for dynamic JSON

For reading dynamic JSON. No reflection, no unsafe, allocates less memory than encoding/json.

github.com/antonholmquist/jason

GoDoc Go project version Report card License MIT

Easy-to-use JSON Library for Go

Digging through the map[string]interface{} that is needed when dealing with dynamic JSON with encoding/json is inconvenient. Jason provides a more convenient API designed to work well for common use cases. It is focuses on reading instead of creating.

github.com/bitly/go-simplejson

GoDoc Go project version Report card License MIT

a Go package to interact with arbitrary JSON

Wraps encoding/json to hide the type assertions needed for dealing with dynamic JSON (e.g., map[string]interface{}) in Go.

github.com/buger/jsonparser

GoDoc Go project version Report card License MIT

Alternative JSON parser for Go that does not require schema (so far fastest)

Extract values from JSON without allocating memory. Read only.

github.com/cthulhu/jsonpath

GoDoc Go project version Report card License MIT

JSONPath with dot notation generator for golang

Use a dot notation to define deeply nested JSON documents without needing to create the nested structs yourself.

github.com/json-iterator/go

GoDoc Go project version Report card License MIT

jsoniter (json-iterator) is a fast and flexible JSON parser available in Java and Go

jsoniter provides three APIs to choose from to match your use case. The Bind-API converts JSON to native Go types. The Iterator-API is for when you don’t need to get all the data back, allowing you to iterate over the JSON data itself. The Any-API is for when the JSON is too dynamic for the other approaches.

github.com/panthesingh/goson

GoDoc Go project version Report card License MIT

Handle JSON with ease in golang.

A fluent interface for traversing JSON data.

github.com/tidwall/gjson

GoDoc Go project version Report card License MIT

Get JSON values quickly - JSON Parser and Unmarshaller for Go

Extract specific values or sets of values using a dot notation path. Also has a drop-in replacement for json.Unmarshal that is 3-4 times faster. If the JSON data is not well formed, unexpected results may be returned.

Dig into the Fundamentals of Go

Subscribe to receive a weekly email covering a Go fundamental. Be it the language, its tooling, or its packages, you will learn what you need to know.