This is a JSON parsing library for ZScript.
Includes a usage example and a small test suite.
It supports, in addition to strict JSON: trailing commas, single-quote strings, and single/multi-line comments (C/C++-style).
To use in your mod, just generate the prefixes, copy over the generated/ZJSON folder, and add #include "ZJSON/Include.zs" to your main ZScript file.
Run generate.sh [your prefix] on linux/wsl/msys/cygwin. The prefixed files will be in the generated folder.
Call JSON.parse with a string that contains JSON text, it will return either a JsonElement in case of success, or a JsonError in case of failure. Call JsonElement::serialize to generate JSON back from a JsonElement.
- JsonError - NOT a Json Element. If
JSON.parsereturn this, it means that the parsing failed, the error is inJsonError.what, it contains line number and some extra information. - JsonElement - One of
JsonObject,JsonArray,JsonString,JsonNumber,JsonBool, orJsonNull - JsonObject - Hash Table that holds
JsonElementvalues withStringkeys - JsonArray - Dynamic Array that holds
JsonElementvalues - JsonString - String Literal
- JsonNumber - One of
JsonIntorJsonDouble - JsonInt - Integral Literal
- JsonDouble - Decimal Literal
- JsonBool - A
true/falseLiteral - JsonNull - A
nullLiteral