jasper

Types

pub type Indentation {
  Spaces(Int)
  Tab
  Tabs(Int)
}

Constructors

  • Spaces(Int)
  • Tab
  • Tabs(Int)
pub type JsonArray =
  List(JsonValue)
pub type JsonObject =
  Dict(String, JsonValue)
pub type JsonQuery {
  Root
  Key(query: JsonQuery, key: String)
  KeyOr(query: JsonQuery, key: String, or: JsonValue)
  Index(query: JsonQuery, index: Int)
  IndexOr(query: JsonQuery, index: Int, or: JsonValue)
  Filter(query: JsonQuery, predicate: fn(JsonValue) -> Bool)
  Map(query: JsonQuery, mapping: fn(JsonValue) -> JsonValue)
  MapKeys(query: JsonQuery, mapping: fn(String) -> String)
  MapValues(
    query: JsonQuery,
    mapping: fn(String, JsonValue) -> JsonValue,
  )
  FilterMap(
    query: JsonQuery,
    mapping: fn(JsonValue) -> Result(JsonValue, Nil),
  )
  ForEach(query: JsonQuery)
  ForEachOk(query: JsonQuery)
}

Constructors

  • Root
  • Key(query: JsonQuery, key: String)
  • KeyOr(query: JsonQuery, key: String, or: JsonValue)
  • Index(query: JsonQuery, index: Int)
  • IndexOr(query: JsonQuery, index: Int, or: JsonValue)
  • Filter(query: JsonQuery, predicate: fn(JsonValue) -> Bool)
  • Map(query: JsonQuery, mapping: fn(JsonValue) -> JsonValue)
  • MapKeys(query: JsonQuery, mapping: fn(String) -> String)
  • MapValues(
      query: JsonQuery,
      mapping: fn(String, JsonValue) -> JsonValue,
    )
  • FilterMap(
      query: JsonQuery,
      mapping: fn(JsonValue) -> Result(JsonValue, Nil),
    )
  • ForEach(query: JsonQuery)
  • ForEachOk(query: JsonQuery)
pub type JsonQueryError {
  UnexpectedType(JsonValue)
  MissingObjectKey(JsonValue, key: String)
  IndexOutOfBounds(JsonValue, index: Int)
}

Constructors

  • UnexpectedType(JsonValue)
  • MissingObjectKey(JsonValue, key: String)
  • IndexOutOfBounds(JsonValue, index: Int)
pub type JsonValue {
  Object(JsonObject)
  Array(JsonArray)
  String(String)
  Number(Float)
  Boolean(Bool)
  Null
}

Constructors

  • Object(JsonObject)
  • Array(JsonArray)
  • String(String)
  • Number(Float)
  • Boolean(Bool)
  • Null
pub type ParseError {
  UnexpectedToken(found: Char)
  UnexpectedEndOfInput
}

Constructors

  • UnexpectedToken(found: Char)
  • UnexpectedEndOfInput

Functions

pub fn parse_json(value: String) -> Result(JsonValue, ParseError)
pub fn parse_jsonl(
  value: String,
) -> Result(List(JsonValue), ParseError)
pub fn parse_jsonl_all(
  value: String,
) -> List(Result(JsonValue, ParseError))
pub fn parse_jsonl_valid(value: String) -> List(JsonValue)
pub fn query_json(
  json: JsonValue,
  query: JsonQuery,
) -> Result(JsonValue, JsonQueryError)
pub fn stringify_json(value: JsonValue) -> String
pub fn stringify_json_spaced(
  value: JsonValue,
  indentation: Indentation,
) -> String
pub fn stringify_jsonl(values: List(JsonValue)) -> String
Search Document