just.toJSON(value) → {*}
If value is an object, return value, otherwise parse value using JSON.parse(). Return null if an exception occurs.
- Since:
- 1.0.0-rc.23
- Source:
- parseJSON.js, line 28
Parameters:
| Name | Type | Description |
|---|---|---|
| value | Any | Some value. |
Returns:
The given value (if it's an object), the parsed value or null.
- Type
- Any
Examples
parseJSON('{"a": 1}'); // > {a: 1}parseJSON('[]'); // > []parseJSON(''); // > nullparseJSON({}); // > nullparseJSON(1); // > 1