import { ViewOf } from "atom.io/foundations/type-utils"; //#region src/foundations/json/index.d.ts type primitive = boolean | number | string | null; declare namespace Json { namespace Tree { type Array = ReadonlyArray; type Object = Record; type Fork = Array | Object; type Leaf = primitive; type Node = Fork | Leaf; } type Serializable = primitive | Readonly<{ [key: string]: Serializable; }> | ReadonlyArray; type Object = Record; type Array = ReadonlyArray; } /** A generic that retains the type information of a {@link Json.Serializable} value while in string form */ type stringified = J extends string ? `"${J}"` : J extends number ? `${J}` : J extends true ? `true` : J extends false ? `false` : J extends boolean ? `false` | `true` : J extends null ? `null` : J extends [] ? `[]` : J extends [infer Element extends Json.Serializable] ? `[${stringified}]` : J extends [infer Element1 extends Json.Serializable, infer Element2 extends Json.Serializable] ? `[${stringified}, ${stringified}]` : J extends [infer Element1 extends Json.Serializable, infer Element2 extends Json.Serializable, infer Element3 extends Json.Serializable] ? `[${stringified}, ${stringified}, ${stringified}]` : J extends any[] ? `[${string}]` & { __json?: J; } : string & { __json?: J; }; /** Type-safe wrapper for {@link JSON.parse} */ declare function parseJson(str: stringified): J; /** Type-safe wrapper for {@link JSON.parse} */ declare function parseJson(str: string): Json.Serializable; /** Type-safe wrapper for {@link JSON.stringify} */ declare const stringifyJson: (json: J) => stringified; /** A function whose parameters and return value are {@link Json.Serializable} */ type JsonIO = (...params: Json.Serializable[]) => Json.Serializable | void; type JsonInterface = { toJson: (t: ViewOf) => J; fromJson: (json: J) => T; }; declare function isJson(input: unknown): input is Json.Tree.Node; declare const JSON_TYPE_NAMES: readonly ["array", "boolean", "null", "number", "object", "string"]; type JsonTypeName = (typeof JSON_TYPE_NAMES)[number]; interface JsonTypes extends Record { array: Json.Array; boolean: boolean; null: null; number: number; object: Json.Object; string: string; } declare const JSON_DEFAULTS: JsonTypes; //#endregion export { JSON_DEFAULTS, JSON_TYPE_NAMES, Json, JsonIO, JsonInterface, JsonTypeName, JsonTypes, isJson, parseJson, primitive, stringified, stringifyJson }; //# sourceMappingURL=index.d.ts.map