apps-script-utils 2.1.1 Help

stringifyJson

function stringifyJson(value: unknown): string;

JSON.stringify writes keys in insertion order, so two objects that carry the same data can produce different text. Here the keys of every object are sorted, which makes the output a stable key — for a cache, a checksum or a comparison.

It is what hashCode hashes, and the reason two equal objects hash alike.

Parameters

Parameter

Type

Description

value

unknown

The value to serialise.

Returns

string — the JSON text, with object keys sorted.

Examples

Serialising

stringifyJson({ b: 1, a: 2 }); // => "{\"a\":2,\"b\":1}" stringifyJson([1, "a", null]); // => "[1,\"a\",null]"

See also

Source

src/json/stringifyJson.ts

23 September 2026

This documentation was generated with AI (Claude) from the library's source code.