agnostic/internals/json_object_builder
This module contains helper functions for building up json objects using pipelines. This allows us to skip “empty” values, reducing payload size.
It builds up a list of entries in reverse; but since we do not care about the order of our keys, we can just leave the list like it is.
Types
Values
pub fn bool(
entries: List(#(String, json.Json)),
key: String,
value: Bool,
) -> List(#(String, json.Json))
pub fn int(
entries: List(#(String, json.Json)),
key: String,
value: Int,
) -> List(#(String, json.Json))
pub fn json(
entries: List(#(String, json.Json)),
key: String,
value: json.Json,
) -> List(#(String, json.Json))
pub fn list(
entries: List(#(String, json.Json)),
key: String,
values: List(a),
to_json: fn(a) -> json.Json,
) -> List(#(String, json.Json))
pub fn object(
entries: List(#(String, json.Json)),
key: String,
nested: List(#(String, json.Json)),
) -> List(#(String, json.Json))