isJsonc
Checks whether a value is a string holding valid JSONC — JSON with comments and trailing
commas, the dialect of tsconfig.json and VS Code’s settings.json, also known as HuJSON or
JWCC (JSON With Commas and Comments).
Strict JSON is valid JSONC too, so this is true for everything isJSON accepts, plus
line and block comments, trailing commas before } and ], and a leading byte order mark.
JSON5 syntax isn’t JSONC — use isJson5 for that (parse from @helpers4/json reads
both).
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 JSON or JSONC
Examples
Section titled “Examples”Check a JSONC string
Section titled “Check a JSONC string”Comments and trailing commas are fine; strict JSON is too.
JSON5 is not JSONC
Section titled “JSON5 is not JSONC”Single quotes and unquoted keys are rejected.
