json_value

A JSON value representation that can be used to decode arbitrary JSON into json_value.JsonValue that can be manipulated and turned back into JSON again.

Types

pub type JsonValue {
  Null
  String(String)
  Int(Int)
  Bool(Bool)
  Float(Float)
  Array(List(JsonValue))
  Object(dict.Dict(String, JsonValue))
}

Constructors

Values

pub fn array(
  values: List(a),
  mapper: fn(a) -> JsonValue,
) -> JsonValue

Create a JSON array by mapping a list of values into JsonValues.

pub const bool: fn(Bool) -> JsonValue

A JsonValue representing a boolean.

pub fn decoder() -> decode.Decoder(JsonValue)

Decodes a value into an json_value.Json.

pub const float: fn(Float) -> JsonValue

A JsonValue representing a float.

pub const int: fn(Int) -> JsonValue

A JsonValue representing an integer.

pub const null: JsonValue

A JsonValue representing null.

pub fn object(entries: List(#(String, JsonValue))) -> JsonValue

Create a JSON object from a list of key-value pairs.

pub fn parse(json: String) -> Result(JsonValue, json.DecodeError)

Parse a String to a json_value.Json

pub fn parse_bits(
  json: BitArray,
) -> Result(JsonValue, json.DecodeError)

Parse a BitArray to a json_value.Json

pub const string: fn(String) -> JsonValue

A JsonValue representing a string.

pub fn to_json(value: JsonValue) -> json.Json

Convert a JsonValue to a json.Json value.

pub fn to_string(value: JsonValue) -> String

Convert a json_value.Json to a JSON string.

pub fn to_string_tree(value: JsonValue) -> string_tree.StringTree

Convert a json_value.Json to a string_tree.StringTree

Search Document