isJson5
Checks whether a value is a string holding valid JSON5 (JSON5 1.0.0) — JSON with comments,
trailing commas, unquoted keys, single-quoted strings, hexadecimal numbers, Infinity/NaN
and more.
JSON5 is a superset of JSONC, itself a superset of JSON, so this is true for everything
isJSON and isJsonc accept. It accepts exactly what parse from
@helpers4/json accepts — see there for the full list.
Available since v3.1.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
Section titled “Returns”value is string — true if value is a string holding JSON5
Examples
Section titled “Examples”Check a JSON5 string
Section titled “Check a JSON5 string”Unquoted keys, single quotes, hexadecimal numbers and trailing commas are JSON5.
Keys that are not identifiers need quotes
Section titled “Keys that are not identifiers need quotes”A dash is not allowed in an unquoted key.
