sparkling/encode
Values
pub fn array(
items: List(a),
encoder: fn(a) -> json.Json,
) -> json.Json
Helper: encode a list of values.
pub fn clickhouse_map_from_dict(
m: dict.Dict(String, json.Json),
) -> json.Json
Generic encoder for maps where keys are strings
pub fn clickhouse_tuple(elements: List(json.Json)) -> json.Json
Encode Tuple represented as List(Json) to JSON array
pub fn datetime64(dt: types.DateTime64) -> json.Json
Encode DateTime64 to JSON string (ISO 8601 format)
pub fn decimal(d: types.Decimal) -> json.Json
Encode Decimal to JSON string (preserves precision)
pub fn encode_json_each_row(
records: List(dict.Dict(String, json.Json)),
) -> String
Encode multiple records to JSONEachRow format (newline-separated JSON objects). Uses efficient string.join for better performance with large batches.
pub fn encode_record(
record: dict.Dict(String, json.Json),
) -> String
Encode a record (represented as a Dict) to a JSON object. This is useful for JSONEachRow format where each row is a JSON object.
pub fn low_cardinality_string(
lc: types.LowCardinality,
) -> json.Json
Encode LowCardinality(String) to JSON string
pub fn nested_from_dict(
fields: dict.Dict(String, json.Json),
) -> json.Json
Encode Nested structure represented as Dict(String, Json) to JSON object
pub fn nullable(value: option.Option(json.Json)) -> json.Json
Helper: create a JSON field for a nullable value.