Saltar al contenido principal

Function: useJsonParse()

useJsonParse<T>(json): T

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

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

Type Parameters

T

T = unknown

Parameters

json

string

The JSON string to parse.

Returns

T

The parsed value typed as T.

Example

import { useJsonParse } from "katanakit-js";

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