main.bend checks
raw source on the hub · import bend-toon-codec@0.1.0.0/main.bend as Main
4 imports
import Base import ./src/json.bend as I import ./src/encode.bend as Enc import ./src/decode.bend as Dec
Types
type Json source · line 23 · raw
Data
JSON values. Arrays and objects are chains inside Json itself: an array is JArr{JCons{a, JCons{b, JNil{}}}}, an object is JObj{JField{"k", v, JField{"k2", v2, JNil{}}}}. Numbers keep their decimal text (JNum{"1.50"}); encode writes the canonical form.
JNullJson
JBool@b:Bool -> Json
JNum@text:String -> Json
JStr@s:String -> Json
JArr@items:Json -> Json
JObj@fields:Json -> Json
JNilJson
JCons@head:Json -> @tail:Json -> Json
JField@key:String -> @val:Json -> @tail:Json -> Json
type Delim source · line 35 · raw
Data
Delimiter of arrays and tabular rows.
CommaDelim
TabDelim
PipeDelim
type EncodeOpts source · line 43 · raw
Data
Spaces per indent level, the document delimiter, and key folding: 0 is off
(the default), n of 2 or more folds chains of single-key objects into dotted
keys of at most n segments (a.b.c: 1), 4294967295 folds whole chains.
EncodeOpts@indent:U32 -> @delim:Delim -> @fold:U32 -> EncodeOpts
type DecodeOpts source · line 49 · raw
Data
Spaces per indent level (used to compute line depth), strict mode (counts,
indentation, blank lines, duplicate keys), and path expansion (an unquoted
key a.b.c becomes nested objects; quoted keys stay literal).
DecodeOpts@indent:U32 -> @strict:Bool -> @expand:Bool -> DecodeOpts
Definitions
def encode_default source · line 53 · raw
EncodeOpts
Indent 2, comma.
def decode_default source · line 57 · raw
DecodeOpts
Indent 2, strict.
def to_inner source · line 62 · raw
@j:Json -> 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json
def of_inner source · line 83 · raw
@j:0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json -> Json
def of_inner_result source · line 104 · raw
@r:Result<&2, &2, String, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/json.Json> -> Result<&2, &2, String, Json>
def inner_delim source · line 111 · raw
@d:Delim -> 0x12996a27cbeef5e5ba1e8cd909be0e05/src/encode.Delim
def encode source · line 124 · raw
@j:Json -> @o:EncodeOpts -> String
TOON text of a value, LF line endings, no trailing newline. NaN and Infinity (a JNum whose text is not a number) encode as null.
def decode source · line 130 · raw
@s:String -> @o:DecodeOpts -> Result<&2, &2, String, Json>
The value of TOON text, or the first error with its line number.
def eq source · line 137 · raw
@a:Json -> @b:Json -> Bool
JSON-model equality: numbers by value (1.0 equals 1), objects by ordered
keys.