import type { DecodeMode, Decoder, DecodeOutput, DecodeIssue } from 'sts:decode';
import type { EncodeMode, EncodeOutput, Encoder, EncodeIssue } from 'sts:encode';
import { Failure } from 'sts:failures';
import { type Result } from 'sts:result';
import { type Numeric } from './numerics';
export type JsonArray = readonly JsonValue[];
export type JsonObject = {
    readonly [key: string]: JsonValue;
};
export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
type LosslessJsonArray = readonly LosslessJsonValue[];
type LosslessJsonObject = {
    readonly [key: string]: LosslessJsonValue;
};
export type LosslessJsonValue = string | number | bigint | boolean | null | LosslessJsonObject | LosslessJsonArray;
export type JsonLikeArray = readonly JsonLikeValue[];
export type JsonLikeObject = {
    readonly [key: string]: JsonLikeValue;
};
export type JsonLikeValue = string | number | boolean | bigint | null | undefined | JsonLikeObject | JsonLikeArray;
export type MachineJsonArray = readonly MachineJsonLikeValue[];
export type MachineJsonObject = {
    readonly [key: string]: MachineJsonLikeValue;
};
export type MachineJsonLikeValue = string | number | boolean | bigint | null | undefined | Numeric | MachineJsonObject | MachineJsonArray;
export type MachineJsonNumericMode = 'tagged' | 'decimal-string' | 'json-number';
export interface JsonParseOptions {
    int64?: 'default' | 'lossless';
    numerics?: 'tagged';
}
export type JsonStringifyBigintMode = 'number' | 'reject' | 'string';
export interface JsonStringifyOptions {
    int64?: 'default' | 'string' | 'lossless';
    readonly bigint?: JsonStringifyBigintMode;
    numerics?: MachineJsonNumericMode;
}
export declare class JsonParseFailure extends Failure {
    // #[effects(add: [mut])]
    constructor(cause?: unknown);
}
export declare class JsonStringifyFailure extends Failure {
    // #[effects(add: [mut])]
    constructor(cause?: unknown);
}
// #[effects(add: [], unknown: [direct])]
export declare function parseJson(text: string): Result<JsonValue, JsonParseFailure>;
// #[effects(add: [], unknown: [direct])]
export declare function parseJson(text: string, options: JsonParseOptions & {
    int64: 'lossless';
}): Result<LosslessJsonValue, JsonParseFailure>;
// #[effects(add: [], unknown: [direct])]
export declare function parseJson(text: string, options: JsonParseOptions & {
    numerics: 'tagged';
}): Result<MachineJsonLikeValue, JsonParseFailure>;
// #[effects(add: [], unknown: [direct])]
export declare function stringifyJson(value: JsonValue): Result<string, JsonStringifyFailure>;
// #[effects(add: [], unknown: [direct])]
export declare function stringifyJson(value: LosslessJsonValue, options: JsonStringifyOptions & {
    int64: 'string' | 'lossless';
}): Result<string, JsonStringifyFailure>;
// #[effects(add: [], unknown: [direct])]
export declare function stringifyJson(value: MachineJsonLikeValue, options: JsonStringifyOptions & {
    numerics: MachineJsonNumericMode;
}): Result<string, JsonStringifyFailure>;
// #[effects(add: [], forward: [{ from: decoder.decode }], unknown: [direct])]
export declare function parseAndDecode<T, E, M extends DecodeMode>(text: string, decoder: Decoder<T, E, M>): DecodeOutput<T, JsonParseFailure | E, M>;
// #[effects(add: [], forward: [{ from: decoder.validateDecode }], unknown: [direct])]
export declare function validateDecodeJson<T, M extends DecodeMode>(text: string, decoder: Decoder<T, unknown, M>): DecodeOutput<T, readonly DecodeIssue[] | JsonParseFailure, M>;
// #[effects(add: [suspend.await], forward: [{ from: encoder.encode }], unknown: [direct])]
export declare function encodeAndStringify<T, E, M extends EncodeMode>(value: T, encoder: Encoder<T, JsonValue, E, M>): EncodeOutput<string, E | JsonStringifyFailure, M>;
// #[effects(add: [suspend.await], unknown: [direct])]
export declare function validateEncodeJson<T, M extends EncodeMode>(value: T, encoder: Encoder<T, JsonLikeValue, unknown, M>, options?: JsonStringifyOptions): EncodeOutput<string, readonly EncodeIssue[] | JsonStringifyFailure, M>;
// #[effects(add: [mut], forward: [{ from: value.every }], unknown: [direct])]
export declare function isJsonValue(value: unknown): value is JsonValue;
// #[effects(add: [], unknown: [direct])]
export declare function parseJsonLike(text: string): Result<JsonLikeValue, JsonParseFailure>;
// #[effects(add: [], unknown: [direct])]
export declare function stringifyJsonLike(value: JsonLikeValue, options?: JsonStringifyOptions): Result<string, JsonStringifyFailure>;
// #[effects(add: [], forward: [{ from: decoder.decode }], unknown: [direct])]
export declare function decodeJson<T, E>(text: string, decoder: Decoder<T, E, 'sync'>): DecodeOutput<T, E | JsonParseFailure, 'sync'>;
// #[effects(add: [], forward: [{ from: decoder.decode }], unknown: [direct])]
export declare function decodeJson<T, E>(text: string, decoder: Decoder<T, E, 'async'>): DecodeOutput<T, E | JsonParseFailure, 'async'>;
// #[effects(add: [suspend.await], unknown: [direct])]
export declare function encodeJson<T, E>(value: T, encoder: Encoder<T, JsonLikeValue, E, 'sync'>, options?: JsonStringifyOptions): EncodeOutput<string, E | JsonStringifyFailure, 'sync'>;
// #[effects(add: [suspend.await], unknown: [direct])]
export declare function encodeJson<T, E>(value: T, encoder: Encoder<T, JsonLikeValue, E, 'async'>, options?: JsonStringifyOptions): EncodeOutput<string, E | JsonStringifyFailure, 'async'>;
// #[effects(add: [mut], forward: [{ from: value.every }], unknown: [direct])]
export declare function isJsonLikeValue(value: unknown): value is JsonLikeValue;
// #[effects(add: [mut], unknown: [direct])]
export declare function isJsonObject(value: unknown): value is JsonObject;
// #[effects(add: [])]
export declare function emptyJsonRecord(): JsonObject;
// #[effects(add: [], unknown: [direct])]
export declare function copyJsonRecord(value: Readonly<Record<string, JsonValue>>): JsonObject;
// #[effects(add: [], unknown: [direct])]
export declare function mergeJsonRecords(...records: readonly Readonly<Record<string, JsonValue>>[]): JsonObject;
export {};
