Back to Opa

Encoding

docs/docs/policy-reference/builtins/encoding.mdx

1.17.02.5 KB
Original Source

<BuiltinTable category={"encoding"}/>

The json.marshal_with_options builtin's opts parameter accepts the following properties:

FieldRequiredTypeDefaultDescription
prettyNobooltrue if indent or prefix are declared,
false otherwiseEnables multi-line, human-readable JSON output ("pretty-printing").
If this property is true, then objects will be marshaled into multi-line JSON with either user-specified or default indent/prefix options. If this property is false, indent/prefix will be ignored and this builtin functions identically to json.marshal().
indentNostring"\t"
(Horizontal tab, character 0x09)The string to use when indenting nested keys in the emitted JSON. One or more copies of this string will be included before child elements in every object or array.
prefixNostring""
(empty)The string to prefix lines with in the emitted JSON. One copy of this string will be prepended to each line.

Default values will be used if:

  • opts is an empty object.
  • opts does not contain the named property.

Examples

<PlaygroundExample dir={require.context("../_examples/encoding/envoy_header_manipulation")} />