Browse the docs

jsonText

Turns a value into compact JSON text.

Details #

jsonText(value) takes exactly one argument and returns one line of JSON text with no spaces. Record keys are sorted alphabetically and / is not escaped. Use it to pass a list or record to a shell command, a web request body or a file.

Parameters #

Takes 1 argument. {{ jsonText(text) }}

Examples #

jsonText(rec)
→ {"a":1,"b":2}
Sample variableValue
rec{"a": 1, "b": 2}
jsonText([1, "a", true])
→ [1,"a",true]
jsonText("hi")
→ "hi"

The three results are {"a":1,"b":2}, [1,"a",true] and "hi" (with its quotes).

Gotchas #

  • string gives the same compact JSON for a list or record, but leaves text and numbers without JSON quotes.