glee

Glee A simple way to parse JSON without having to implement the JSON module. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ This is my first time using Gleam, so I’m sure there are some things that could be done better.

Functions

pub fn create_json_object(key: String, value: String) -> String

Create a simple JSON object with a single key-value pair

pub fn create_json_object_from_pairs(
  pairs: List(#(String, String)),
) -> String

Create a JSON object from multiple key-value pairs

pub fn encode_bool(value: Bool) -> String

Encode a boolean value into a JSON string

pub fn encode_float(value: Float) -> String

Encode a float value into a JSON string

pub fn encode_int(value: Int) -> String

Encode an int value into a JSON string

pub fn encode_list(values: List(String)) -> String

Encode a list of values into a JSON array string

pub fn encode_object(values: Dict(String, String)) -> String

Encode a map of string keys and string values into a JSON object string

pub fn encode_string(value: String) -> String

Encode a string value into a JSON string

pub fn extract_value_from_json(
  json: String,
  parent: String,
  key: String,
) -> String

Extract a value from a JSON string by specifying the parent and key.

pub fn parse_json_float(
  json: String,
  field: String,
) -> Result(Float, String)

Parse a JSON string and return the float value of a given field.

pub fn parse_json_int(
  json: String,
  field: String,
) -> Result(Int, String)

Parse a JSON string and return the int value of a given field.

pub fn parse_json_string(
  json: String,
  field: String,
) -> Result(String, String)

Parse a JSON string and return the string value of a given field.

Search Document