/** * Python json module for TypeScript * * Provides JSON encoding and decoding functions matching Python's json module. * Maps directly to JavaScript's JSON object with Python-compatible options. * * @see {@link https://docs.python.org/3/library/json.html | Python json documentation} * @module */ type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue; }; interface DumpsOptions { /** If specified, use this many spaces for indentation */ indent?: number; /** Separators for items and key-value pairs [item_sep, key_sep] */ separators?: [string, string]; /** Sort dictionary keys */ sortKeys?: boolean; /** If false, non-ASCII characters are escaped. Default true */ ensureAscii?: boolean; /** Custom serialization function */ default?: (obj: unknown) => JsonValue; } interface LoadsOptions { /** Custom deserialization function */ objectHook?: (obj: Record) => unknown; /** Parse floats with this function */ parseFloatFn?: (s: string) => number; /** Parse integers with this function */ parseIntFn?: (s: string) => number; } /** * Serialize obj to a JSON formatted string. * * @param obj - The object to serialize * @param options - Serialization options * @returns JSON string */ declare function dumps(obj: unknown, options?: DumpsOptions): string; /** * Deserialize a JSON string to a Python object. * * @param s - JSON string to parse * @param options - Deserialization options * @returns Parsed object */ declare function loads(s: string, options?: LoadsOptions): unknown; /** * Serialize obj to a JSON formatted string and write to file. * Note: This is a no-op in browser environments. * * @param obj - The object to serialize * @param fp - File-like object with write method * @param options - Serialization options */ declare function dump(obj: unknown, fp: { write: (s: string) => void; }, options?: DumpsOptions): void; /** * Deserialize a JSON string from file to a Python object. * Note: This is a no-op in browser environments. * * @param fp - File-like object with read method * @param options - Deserialization options * @returns Parsed object */ declare function load(fp: { read: () => string; }, options?: LoadsOptions): unknown; declare const jsonModule_dump: typeof dump; declare const jsonModule_dumps: typeof dumps; declare const jsonModule_load: typeof load; declare const jsonModule_loads: typeof loads; declare namespace jsonModule { export { jsonModule_dump as dump, jsonModule_dumps as dumps, jsonModule_load as load, jsonModule_loads as loads }; } export { dumps as a, loads as b, dump as d, jsonModule as j, load as l };