Skip to content

@sqlrooms/utils / safeJsonParse

Function: safeJsonParse()

safeJsonParse<T>(json): null | T

Parse a JSON string and return the parsed object. If the string is not valid JSON, return null.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
jsonundefined | null | stringThe JSON string to parse.

Returns

null | T

The parsed object or null if the string is not valid JSON.