apps-script-utils 2.1.1 Help

parseJson

function parseJson(value: string): object;

JSON.parse runs first. If it refuses, the text is tokenised again by rules that accept what hand-written configuration usually contains: unquoted keys and single-quoted strings.

Text that neither reader can make sense of throws. This is for configuration a person typed, not for a payload from a service — for that, JSON.parse and its error are clearer.

Parameters

Parameter

Type

Description

value

string

The text to parse. It must not be empty.

Returns

object — the parsed value.

Throws

Exception

Condition

EmptyStringException

the value is not a string, or is empty.

SyntaxError

neither reader can parse the text.

Examples

Parsing

parseJson('{"a":1,"b":[1,2]}'); // => {"a":1,"b":[1,2]} parseJson("{a: 'x', b: 1}"); // => {"a":"x","b":1}

See also

Source

src/json/parseJson.ts

23 September 2026

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