json#

Type Aliases#

Json#

Json = null | boolean | string | JsonNumber | JsonArray | JsonObject

Defined in: json.ts:18

A JSON value as parse returns it.


JsonObject#

JsonObject = object

Defined in: json.ts:21

A JSON object: string keys to JSON values.

Index Signature#

[key: string]: Json


PathSegment#

PathSegment = string | number

Defined in: json.ts:15

One step of a path into a JSON value: an object key or an array index.

Functions#

canonicalText()#

canonicalText(value): string

Defined in: json.ts:34

The canonical text of a value, which equal values share: TimeToShare’s compactSortedJson (no whitespace, every object’s keys sorted by code point, an integer and a float of equal value apart). The writer refuses, with a TypeError, any value that is not JSON, whatever its declared type.

Parameters#

value#

unknown

Returns#

string


compareCodePoints()#

compareCodePoints(left, right): number

Defined in: json.ts:87

-1, 0 or 1 by Unicode code points, not by UTF-16 units as JavaScript’s < compares.

Parameters#

left#

string

Returns#

number


isJsonObject()#

isJsonObject(value): value is JsonObject

Defined in: json.ts:24

Whether value is a JSON object: not an array, not a JsonFloat.

Parameters#

value#

unknown

Returns#

value is JsonObject


jsonEqual()#

jsonEqual(left, right): boolean

Defined in: json.ts:52

Whether two JSON values are equal: same members, same numbers of the same kind (an integer never equals a float), whatever the order of keys. An absent value (undefined) equals only an absent value.

Parameters#

left#

unknown

right#

unknown

Returns#

boolean


showJson()#

showJson(value): string

Defined in: json.ts:39

A short text of any value for a message: its canonical JSON when it has one.

Parameters#

value#

unknown

Returns#

string


withValueAt()#

withValueAt(value, path, replacement): unknown

Defined in: json.ts:66

value with what lies at path replaced by replacement, every object and list on the way copied and the rest kept as it is; a member missing on the way becomes an empty object. An index names an item of a list, or the place after its last item.

Parameters#

value#

unknown

path#

readonly PathSegment[]

replacement#

unknown

Returns#

unknown

Throws#

if an index meets no list, or lies beyond its end.