just.parseJSON(value) → {*}
If value is an object, return value, otherwise parse value using JSON.parse(). Return null if an exception occurs.
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
just.parseJSON('{"a": 1}'); // > {a: 1}just.parseJSON('[]'); // > []just.parseJSON(''); // > nulljust.parseJSON({}); // > nulljust.parseJSON(1); // > 1