std/json
import "std/json" as json;parse reads one complete JSON document and returns a failable Value:
var value = json.parse("{\"name\":\"Zap\",\"active\":true}") or err { eprintln(err.message); return 1;};
var object = value.asObject() or err { eprintln(err.message); return 1;};var name = object.getString("name") or err { eprintln(err.message); return 1;};println(name);KindidentifiesString,Number,Boolean,Null,Object, orArray.Valuehas constructors for every JSON kind, predicates such asisArray(), checked accessorsasString(),asInt(),asUInt(),asFloat64(),asBool(),asObject(), andasArray(), plusstringify().Objectprovides overloadedput,putNull,has,size,get,keyAt, typedgetString,getInt,getUInt,getFloat64,getBool,getObject, andgetArray, plusstringify().Arrayprovides overloadedpush,pushNull,size,at, the matching typed getters, andstringify().
parse(text) and parse(text, maxDepth) report json.Error on invalid JSON.
The checked accessors and serializers use the same error type. JSON strings,
numbers, booleans, nulls, objects, arrays, escapes, and nested values are
supported.