Skip to content

print_ndjson

Transforms a value into a single-line JSON string.

print_ndjson(input:any, [strip=bool, color=bool, arrays_of_objects=bool,
strip_null_fields=bool, strip_nulls_in_lists=bool,
strip_empty_records=bool, strip_empty_lists=bool]) -> string

Transforms a value into a single-line JSON string.

The value to print as a JSON value.

Enables all strip_* options.

Defaults to false.

Colorize the output.

Defaults to false.

Strips all fields with a null value from records.

Defaults to false.

Strips all null values from lists.

Defaults to false.

Strips empty records, including those that only became empty by stripping.

Defaults to false.

Strips empty lists, including those that only became empty by stripping.

Defaults to false.

from {x: 0},
{x:null},
{x: {x: 0, y: 1}},
{x: [0,1,2,]}
x = x.print_ndjson(strip_null_fields=true)
{
x: "0",
}
{
x: null,
}
{
x: "{\"x\": 0, \"y\": 1}",
}
{
x: "[0, 1, 2]",
}

write_ndjson, print_json, parse_json