Namespace: parseJSON

just.parseJSON(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:
just.js, line 1600

Parameters:

NameTypeDescription
value
AnySome value.

Returns:

The given value (if it's an object), the parsed value or null.
Type
Any

Examples

Example 1.
just.parseJSON('{"a": 1}'); // > {a: 1}
Example 2.
just.parseJSON('[]'); // > []
Example 3.
just.parseJSON(''); // > null
Example 4.
just.parseJSON({}); // > null
Example 5.
just.parseJSON(1); // > 1