niffler_precompiled/json

A small, strict JSON reader/writer used for manifests and for reading gleam export package-information output.

We deliberately avoid a JSON dependency: the runtime library must be stdlib-only, and manifest parsing is on the trusted path.

Types

pub type Json {
  JNull
  JBool(Bool)
  JInt(Int)
  JFloat(Float)
  JString(String)
  JArray(List(Json))
  JObject(List(#(String, Json)))
}

Constructors

  • JNull
  • JBool(Bool)
  • JInt(Int)
  • JFloat(Float)
  • JString(String)
  • JArray(List(Json))
  • JObject(List(#(String, Json)))

Values

pub fn as_array(json: Json) -> Result(List(Json), String)
pub fn as_int(json: Json) -> Result(Int, String)
pub fn as_object(
  json: Json,
) -> Result(List(#(String, Json)), String)
pub fn as_string(json: Json) -> Result(String, String)
pub fn encode(json: Json) -> String
pub fn escape_string(value: String) -> String
pub fn field_array(
  json: Json,
  key: String,
) -> Result(List(Json), String)
pub fn field_int(json: Json, key: String) -> Result(Int, String)
pub fn field_optional_string(
  json: Json,
  key: String,
) -> Result(option.Option(String), String)
pub fn field_string(
  json: Json,
  key: String,
) -> Result(String, String)
pub const max_depth: Int
pub const max_size: Int
pub fn object_get(
  json: Json,
  key: String,
) -> Result(Json, String)
pub fn parse(input: String) -> Result(Json, String)
✨ Search Document