glean/json_value

Types

A generic JSON value that can represent any JSON data.

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

Constructors

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

Values

pub fn arguments_to_object(arguments_json: String) -> json.Json

Turn a tool call’s argument string into a JSON object for APIs that take arguments as an object (Anthropic input, Gemini args).

Arguments that aren’t a JSON object can’t be sent as-is. They were already reported to the model as invalid when the tool call ran, so they are sent back wrapped as {"invalid_arguments": "<original text>"} rather than dropped, keeping the history truthful.

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

Decoder for arbitrary JSON values.

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

Convert a JsonValue to a gleam/json Json for embedding in JSON output.

pub fn to_string(value: JsonValue) -> String

Convert a JsonValue to a JSON string.

✨ Search Document