jelly

Types

From gleam/json

pub type DecodeError {
  UnexpectedEndOfInput
  UnexpectedByte(String)
  UnexpectedSequence(String)
}

Constructors

  • UnexpectedEndOfInput
  • UnexpectedByte(String)
  • UnexpectedSequence(String)

Represents a JSON tree of arbitrary schema

pub type JsonType {
  Unknown
  Null
  Bool(Bool)
  Float(Float)
  Int(Int)
  String(String)
  Array(List(JsonType))
  Object(Dict(String, JsonType))
}

Constructors

  • Unknown
  • Null
  • Bool(Bool)
  • Float(Float)
  • Int(Int)
  • String(String)
  • Array(List(JsonType))
  • Object(Dict(String, JsonType))

Functions

pub fn dynamic_to_json(from value: Dynamic) -> JsonType

Converts any Dynamic into a JsonType which can be matched on to extract the data. If conversion fails for a given property, Unknown is returned.

pub fn parse(from json: String) -> Result(JsonType, DecodeError)

Parses a string into a JsonType which can be matched on to extract the data. If decoding fails for a given property, Unknown is returned.

pub fn parse_dict(
  json: String,
) -> Result(Dict(Dynamic, Dynamic), DecodeError)

Parses a string into a Dict of Dynamic values

pub fn path(
  json: JsonType,
  path: String,
) -> Result(JsonType, Nil)

Select a nested value from a JsonType object using a path expression (e.g. “a.b.c[3]”). Returns Nil if the path does not lead to a value.

Search Document