Skip to content
0

katanakit-js / useJsonParse

Function: useJsonParse() ​

ts
function useJsonParse<T>(json): T;

Defined in: src/core/services/formatter.service.ts:184

Pure: parse JSON (throws on invalid input — same as JSON.parse).

Type Parameters ​

Type ParameterDefault type
Tunknown

Parameters ​

ParameterTypeDescription
jsonstringThe JSON string to parse.

Returns ​

T

The parsed value typed as T.

Example ​

ts
import { useJsonParse } from "katanakit-js";

const obj = useJsonParse<{ a: number }>('{"a":1}');
// { a: 1 }

Released under the MIT License.