moonjson — the JSON family for MoonBit: RFC 8259 JSON, JSONC, JSON5 and JSON Lines over one data model, with JSON Pointer, and failures that name the line and column.
let config = @json.parse("{\"host\":\"localhost\",\"port\":8080}")
@json.write(config) // {"host":"localhost","port":8080}
@json.write(config, indent=2) // over several lines
// The same document, written the way a settings file is written.
@jsonc.parse("{\"port\": 8080, // the one we bound\n}")
// One place in a document, named (RFC 6901).
@pointer.get(config, "/host") // "localhost"| Package | What | Specification |
|---|---|---|
| json | JSON, exactly | RFC 8259, ECMA-404 |
| jsonc | JSON with comments and trailing commas | what VS Code accepts |
| json5 | JSON5: unquoted names, single quotes, hexadecimal, Infinity | spec.json5.org |
| lines | JSON Lines / NDJSON: one document to a line | jsonlines.org |
| pointer | JSON Pointer | RFC 6901 |
| moonjson | The scanner the dialects share, the writer, and Flavor | — |
try @json.parse(source) catch {
e => println("line \{e.at().line}, column \{e.at().column}")
}moon add moonbitstack/moonjsonlet depth_limit : IntInstall
Download zipmoonjson — the JSON family for MoonBit: RFC 8259 JSON, JSONC, JSON5 and JSON Lines over one data model, with JSON Pointer, and failures that name the line and column.