IF Commons GitHub

governance/json

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-archon-governance FR-003

Data, the only thing a requirement may ask for: a value of JSON, with a canonical text in which the keys are in a fixed order, so that two values that are equal are the same text.

import { canonicalJson } from "./json.ts";
canonicalJson({ b: 1, a: [true, null] }); // '{"a":[true,null],"b":1}'

Source: commons/archon/src/governance/json.ts

2 of 4 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

JsonValuetype
type JsonValue = null | boolean | number | string | readonly JsonValue[] | { readonly [key: string]: JsonValue };

A value of JSON.

Imported by 12 tests of the run (12 passed, 0 failed): the library's results

isJsonfunctionno test imports it
function isJson(value: unknown): value is JsonValue

Whether an unknown value is data: null, a boolean, a finite number, a string, a list of data or a plain object of data.

canonicalJsonfunction
function canonicalJson(value: JsonValue): string

The text of a value with the keys of every object in order, no space, and nothing that depends on the order they were made in.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

sameJsonfunctionno test imports it
function sameJson(a: JsonValue, b: JsonValue): boolean

Whether two values are the same data, whatever the order of the keys.

Titles, headings, exports, tables, columns and requirements. Esc closes.