std/json
import "std/json" as json;JsonParser parses one value and reports validity through fields on the parser
and result:
var parser = new json.JsonParser("{\"name\":\"Zap\"}");var value = parser.parse();
if !value.valid { eprintln("invalid JSON"); return 1;}JsonTypeidentifiesSTRING,NUMBER,BOOL,NULLTYPE, orOBJECT.JsonValuestores the tag, value fields, original object source, andvalid.JsonObjectprovidesput,get,has, andsize.JsonParserexposes lower-level cursor and parsing methods in addition toparse.
The module is an early implementation, not a complete JSON codec. Object and
string parsing work, while numbers, booleans, null, arrays, escaping, and
serialization are not yet fully implemented. Check valid before using a
parsed value.