json.ts

Declarations
#

8 declarations

view source

Json
#

json_embed
#

json.ts view source

<T>(data: T, stringify?: (data: T) => string): string

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

json_stringify_deterministic
#

json.ts view source

(value: unknown): string

Serializes a value to JSON with deterministic key ordering. Recursively sorts object keys alphabetically for consistent hashing. Arrays and primitives are serialized as-is.

value

Any JSON-serializable value

type unknown

returns

string

Deterministic JSON string representation

json_type_of
#

json.ts view source

(value: Json): JsonType | undefined

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

value

type Json

returns

JsonType | undefined

JsonArray
#

JsonObject
#

JsonPrimitive
#

JsonType
#

json.ts view source

JsonType

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

Imported by
#