libduvet/json_value

Types

Any JSON value, kept as it came for the places the API’s documents are opaque (a component’s payload, a command option’s value), so that it can go back out unchanged.

pub type JsonValue {
  JsonNull
  JsonBool(Bool)
  JsonInt(Int)
  JsonFloat(Float)
  JsonString(String)
  JsonArray(List(JsonValue))
  JsonObject(dict.Dict(String, JsonValue))
}

Constructors

  • JsonNull
  • JsonBool(Bool)
  • JsonInt(Int)
  • JsonFloat(Float)
  • JsonString(String)
  • JsonArray(List(JsonValue))
  • JsonObject(dict.Dict(String, JsonValue))

Values

pub fn from_dynamic(data: dynamic.Dynamic) -> JsonValue

Reads [data], a value decoded from JSON, as a [JsonValue].

pub fn from_object(
  object: dict.Dict(String, dynamic.Dynamic),
) -> JsonValue

An object already decoded, as a [JsonValue].

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

The same value as [JsonValue], for encoding with gleam/json.

✨ Search Document