toon_codec/encode/arrays

Array encoding functions.

This module handles encoding of JSON arrays to TOON format, including:

Automatically detects the best representation:

Arguments

Examples

tags[3]: admin,ops,dev

Encode an array of primitive arrays in expanded list format.

Examples

pairs[2]:
  - [2]: 1,2
  - [2]: 3,4

Encode an array of uniform objects in tabular format.

Examples

users[2]{id,name}:
  1,Alice
  2,Bob

Encode a mixed/complex array in expanded list format.

Examples

items[3]:
  - 1
  - a: 1
  - text

Encode a single list item (element in expanded array). Encode a complex array as a list item. Encode an object as a list item.

The first field appears on the hyphen line, remaining fields at depth + 1. Encode the first field of an object on the hyphen line. Encode object fields (helper for encoding remaining fields). Encode a key-value pair at a specific depth.

Values

pub fn encode_array(
  key: option.Option(String),
  values: List(types.JsonValue),
  writer: writer.Writer,
  depth: Int,
  options: types.EncodeOptions,
) -> writer.Writer
Search Document