Skip to content

isJSONObject

Checks whether a value is a plain object whose every own value is a valid JSON value (see isJSONValue).

Available since v3.0.3

import { isJSONObject } from '@helpers4/guard';
// or, from the all-in-one package (same code, one install):
import { isJSONObject } from 'helpers4/guard';
isJSONObject(value: unknown): value is Record<string, unknown>
ParameterTypeDescription
valueunknownThe value to check

value is Record<string, unknown> — true if value is a plain object of JSON values

Checks that a value is a plain object whose every value is JSON-representable.

isJSONObject({ a: 1, b: 'two' })
// => true
isJSONObject({ a: undefined })
// => false

View source on GitHub