Jason is designed to be convenient for reading arbitrary JSON while still honoring the strictness of the language. Inspired by other libraries and improved to work well for common use cases. It currently focuses on reading JSON data rather than creating it.


JSON is a commonly used data transfer format, so usually the data you want to read comes either as bytes or as an io.Reader.

Create an object from bytes:

v, err := jason.NewObjectFromBytes(b)

.. or from a net/http response body:

v, err := jason.NewObjectFromReader(res.body)

Read values

Reading values is done with Get<Type>(keys ...) or the generic Get(keys ...). If the key path is invalid or the type doesn't match, it will return an error and the default value.

name, err := v.GetString("name")
age, err := v.GetNumber("age")
verified, err := v.GetBoolean("verified")
education, err := v.GetObject("education")
friends, err := v.GetObjectArray("friends")

Loop through array

Getting an array is done by Get<Type>Array() or the generic GetValueArray(). It returns an error if the value at that keypath is null (or something else than the type).

friends, err := person.GetObjectArray("friends")
for _, friend := range friends {
	name, err := friend.GetString("name")
	age, err := friend.GetNumber("age")

Loop through keys of object

Looping through an object is done by first getting it with `GetObject()` and then range on the Map(). The GetObject() method returns an error if the value at that keypath is null (or something else than an object).

person, err := person.GetObject("person")
for key, value := range person.Map() {

jason is referenced in 25 repositories