vyrn

std/json5

1 export, from std/json5.vyrn.

A JSON5 reader that builds the Json tree of std/json.

import { parseJson5 } from "std/json5"

The reader writes every number in its strict spelling (0x1A -> 26, .5 -> 0.5, +5 -> 5), so emit writes strict JSON for any tree it builds; there is no JSON5 writer. It refuses Infinity, NaN and a hex literal past Int64, because none has an exact strict spelling. An unquoted key is an ASCII identifier ($, _, letters, digits); quote any other key.

Dependencies

The import graph shows the whole library.

Imports
Imported by
fn parseJson5(src: String) -> Result<Json, String>

Parse one JSON5 document: a single value, with gaps (whitespace and comments) allowed around it and nothing after it.

Tests

5 test blocks in std/json5.vyrn. CI runs all of them.

Test names
  • comments, trailing commas, unquoted keys, single quotes
  • numbers normalize to their strict spelling
  • the extra escapes and a continued line
  • extended whitespace and the BOM are gaps
  • the named refusals, and the strictness holes stay closed

Examples

    No example program imports this module.