JSON value type, tag constants, conversion helpers, parser-result types, and serialization helpers.
JSON stores one tagged value over Int64, Real64, Cond, String, JSON Array, and String JSON HashTable.
getTag (-- tag): returns the current JSON tag.setTag (tag --): switches the active JSON tag.getInt, getReal, getCond, getString, getArray, and getObject: typed accessors that require the matching current tag.intAsJSON, realAsJSON, condAsJSON, stringAsJSON, arrayAsJSON, and objectAsJSON: construct one JSON from the corresponding typed value.Object values store one String JSON HashTable, and array values store one JSON Array.
success: TRUE when lexical processing and node parsing succeed and FALSE on invalid UTF-8 input or JSON failure.finished: TRUE when the whole source is consumed after one successful node parse and FALSE when trailing non-space input remains.errorInfo.message: parser failure description when success is FALSE.errorInfo.position: parser position at failure, or the first unparsed position when finished is FALSE.json: parsed JSON value when success is TRUE. When finished is FALSE, it still contains the first parsed node.errorInfo.position.offset is meaningful; line and column are not derived.parseJSONNode: lower-level parser entry that parses one JSON node from one already split UTF-8 source and one current parser position into supplied JSON and JSONParserResult objects.catJSONNodeWithPadding: lower-level serializer helper that appends formatted JSON to one existing String with one requested indentation level.JSONInt; numbers with fractional or exponent part are parsed as JSONReal.Int64 range makes parsing fail.\", \\, \/, \b, \f, \t, \n, \r, and \uXXXX.\uXXXX escapes are interpreted one 16-bit code value at a time. Surrogate-pair combination is unsupported.(source -- result)Parses one accepted UTF-8 source into JSONParserResult.
StringView, Text, and String.String.makeStringView before UTF-8 splitting begins.JSONParserResult.(json -- string)Serializes one JSON value to a formatted String.
true, false, and null.0x10000."Json" use
"control" use
{} () {} [
result: "{\"x\":1}" parseStringToJSON;
@result.@success TRUE same printStack _:;
@result.@finished TRUE same printStack _:;
@[email protected] JSONObject same printStack _:;
@[email protected] 1 same printStack _:;
] "main" exportFunction
TRUE
TRUE
TRUE
TRUE
"Json" use
"control" use
{} () {} [
trailing: "{} x" parseStringToJSON;
@trailing.@success TRUE same printStack _:;
@trailing.@finished FALSE same printStack _:;
@trailing.@errorInfo.@position.@offset 3 same printStack _:;
duplicate: "{\"x\":1,\"x\":2}" parseStringToJSON;
@duplicate.@success FALSE same printStack _:;
] "main" exportFunction
TRUE
TRUE
TRUE
TRUE
"Json" use
"String" use
"control" use
{} Int32 {} [
result: "[1,true]" parseStringToJSON;
result.success ~ [
1
] [
result.json saveJSONToString print
0
] if
] "main" exportFunction
[
1,
true
]