isJSONValue es-toolkit
Checks if a value is a valid JSON value.
Usage
isJSONValue(value)
Use isJSONValue when you want to check if a value can be JSON-serialized. According to JSON specifications, valid values are null, objects, arrays, strings, numbers, and booleans. This function is the foundation for other JSON-related type guards.
Accurately distinguishes values that cannot be JSON-serialized. Functions, undefined, Symbol, class instances, etc. are not supported by JSON specifications and return false:
Useful for data validation before JSON serialization:
Can be combined with other type guards.
Edge cases:
Parameters
The value to check if it's a valid JSON value.
Returns
Returns true if the value is a valid JSON value, false otherwise.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.