mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 12:05:41 +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>
29 lines
705 B
Markdown
29 lines
705 B
Markdown
# 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](./isJSONValue.md).
|
|
|
|
## Signature
|
|
|
|
```typescript
|
|
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
|
|
|
|
```typescript
|
|
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
|
|
```
|