Browse the docs

isJSON

True when text is valid JSON.

Details #

isJSON(value) is true when the text parses as JSON. It never fails, so test before calling json.

Parameters #

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

Examples #

isJSON("{\"a\": 1}")
→ true
isJSON("[1,")
→ false

Gotchas #

  • A lone number or true is valid JSON, so isJSON("42") is true.

  • Only text can be JSON: a list or a record gives false.