mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 03:34:26 +03:00
ded56755f3
* feat:init * feat * fix:use prettier * feat(isPlainObject): Update signature of isPlainObject * feat: Add isJSONValue, isJSONArray, and refactor isJSONObject * remove from functions * docs: Update docs * docs: Update docs * docs: Update docs * docs: Update docs * docs: Update docs * docs: Update docs * docs: Update docs --------- Co-authored-by: Sojin Park <raon0211@gmail.com> Co-authored-by: Sojin Park <raon0211@toss.im>
705 B
705 B
isJSONObject
Checks if a value is a JSON object.
A valid JSON object is defined as an object with string keys and valid JSON values.
Signature
function isJSONObject(obj: unknown): obj is Record<string, any>;
Parameters
value
(unknown
): The value to check.
Returns
(obj is Record<string, any>
): True if the value is a JSON object, otherwise false.
Examples
console.log(isJSONObject({ nested: { boolean: true, array: [1, 2, 3], string: 'test', number: 1, null: null } })); // true
console.log(isJSONObject({})); // true
console.log(isJSONObject({ regexp: /test/ })); // false
console.log(isJSONObject(123)); // false