# gleam_json

A Gleam library for encoding decoding JSON.

### Encoding

import gleam/json

let data = json.object([
  tuple("foo", json.string("bar")),
  tuple("values", json.list([,])),
  tuple("nope", json.null())
// {"foo":"bar","nope":null,"values":[1,2]}

### Decoding

Note: JSON is a dynamic data structure.
The best way to manage decode JSON data is using `gleam/dynamic`.

import gleam/json

let encoded =

assert Ok(data) = json.decode(encoded)
let data = dynamic.from(data)

assert Ok(foo) = dynamic.field(data, "foo")
assert Ok("bar") = dynamic.string(foo)

assert Ok(values) = dynamic.field(data, "values")
assert Ok([1, 2]) = dynamic.typed_list(values,

assert Ok(nope) = dynamic.field(data, "nope")
assert Ok(_) = dynamic.atom(nope)

## Installation

This package can be installed by adding `gleam_json` to your `rebar.config` dependencies:

{deps, [