parseJSON(str: string)
Requires:
@ray-js/panel-sdk≥1.0.0
Description
Safely parse a JSON string into an object
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
str | string | Yes | JSON string to parse |
Return Value
Type: string | Record<string, never>
The parsed object; if parsing fails, returns the original string; if the input is undefined, returns an empty object
Examples
Basic usage
stringifyJSON(data: any)
Requires:
@ray-js/panel-sdk≥1.0.0
Description
Safely serialize the given data to a JSON string
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
data | any | Yes | Data to serialize; can be of any type |
Return Value
Type: string
JSON string representation; if the input is null or undefined, returns an empty string; if the input is already a string, returns it as-is