UNPKG

json-helpers

Version:

JSON stringify/parser managing 'undefined, Date and Buffer.

42 lines (36 loc) 1.51 kB
// Generated by dts-bundle v0.7.3 export namespace ToJSONConstants { const JSON_TOKEN_UNDEFINED = "_/undefined/_"; } export interface JSONLike { stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string; parse(text: string, reviver?: (key: string, value: any) => any): any; } export function IsJSONLike(obj: any): obj is JSONLike; export interface JSONReplacer extends Pick<JSONLike, 'stringify'> { replacer<T>(replacer: JSONReplacerData<T>): void; stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string; } export interface JSONReviver extends Pick<JSONLike, 'parse'> { reviver<T>(reviver: JSONReviverData<T>): void; parse(text: string, reviver?: (key: string, value: any) => any): any; } export interface JSONParserInterface extends JSONReplacer, JSONReviver, JSONLike { formatter<T>(jsonFormatter: JSONFormatterData<T>): void; install(): void; uninstall(): void; } export const JSONParserV1: JSONParserInterface; export const JSONParser: JSONParserInterface; export const JSONParserV2: JSONParserInterface; export interface JSONReviverData<T> { objectType: string; unserialize: (data: any) => T; } export interface JSONReplacerData<T> { objectType: string; objectConstructor: ObjectConstructor; serialize: (t: T) => any; } export interface JSONFormatterData<T> extends JSONReplacerData<T>, JSONReviverData<T> { }