parse-json-object
Version:
Parse a typed JSON object
10 lines (9 loc) • 707 B
TypeScript
import { JSONValue } from "types-json";
import z from "zod";
export type ValidateFunction<T extends JSONValue> = (value: JSONValue) => value is T;
export declare function parse<T extends JSONValue>(text: string | undefined, validator: ValidateFunction<T> | z.ZodSchema<T>): T | undefined;
export declare function parseJSONValue(text?: string): JSONValue | undefined;
export declare function parseJSONObject(text?: string): import("types-json").JSONObject | undefined;
export declare function parseJSONArray(text?: string): import("types-json").JSONArray | undefined;
export declare function parseString(text?: string): string | undefined;
export type { JSONValue, JSONObject, JSONArray } from "types-json";