json.ts

view source

Declarations
#

8 declarations

Json
#

json_embed
#

json.ts view source

<T>(data: T, stringify?: (data: T) => string): string import {json_embed} from '@fuzdev/fuz_util/json.js';

Embeds data as a JSON string, escaping single quotes. Useful for optimizing JSON in JS because it parses faster.

data

type T

stringify

type (data: T) => string
default JSON.stringify

returns

string

generics

json_embed<T>
T

json_stringify_deterministic
#

json.ts view source

(value: unknown): string import {json_stringify_deterministic} from '@fuzdev/fuz_util/json.js';

Serializes a value to JSON with deterministic key ordering. Recursively sorts object keys alphabetically for consistent hashing.

value

type unknown

returns

string

deterministic JSON string representation

json_type_of
#

json.ts view source

(value: Json): JsonType | undefined import {json_type_of} from '@fuzdev/fuz_util/json.js';

Returns the JsonType of value, which is like typeof json but includes 'array' and omits 'undefined'.

value

type Json

returns

JsonType | undefined

JsonArray
#

json.ts view source

JsonArray import type {JsonArray} from '@fuzdev/fuz_util/json.js';

inheritance

extends: Array<Json>

JsonObject
#

json.ts view source

JsonObject import type {JsonObject} from '@fuzdev/fuz_util/json.js';

inheritance

extends: Record<string, Json>

JsonPrimitive
#

json.ts view source

JsonPrimitive import type {JsonPrimitive} from '@fuzdev/fuz_util/json.js';

JsonType
#

json.ts view source

JsonType import type {JsonType} from '@fuzdev/fuz_util/json.js';

Like typeof json, but includes arrays. Excludes 'undefined' because it's not valid JSON.

Imported by
#