json.bend checks
raw source on the hub · import bend-kit-json@0.7.3.1/json.bend as Json
JSON values, parsed and encoded as RFC 8259. Source: https://github.com/paymog/bend-kit/tree/main/json
3 imports
import Base import bend-kit-bytes@0.3.3.2/bytes.bend as Bytes import bend-kit-f64@0.1.4.0/f64.bend as F64
Types
type Val source · line 13 · raw
Type
Num keeps the number's exact text, so no precision is lost. Obj keeps its fields in document order, repeated keys included.
NullVal
Flag@on:Bool -> Val
Num@s:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> Val
Str@s:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> Val
Arr@xs:List<&1, Val> -> Val
Obj@kvs:List<&1, Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, Val)> -> Val
type Open source · line 23 · raw
Type
An open container: array items so far, object fields so far, or those fields and the key whose value comes next. Items and fields are reversed.
OArr@xs:List<&1, Val> -> Open
OObj@kvs:List<&1, Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, Val)> -> Open
OKey@kvs:List<&1, Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, Val)> -> @key:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> Open
type W source · line 32 · raw
Type
Writer ------ Octets being written: the buffer, its size in words, the count so far, and the word being filled. Bytes enter at the top of w, as in Bytes.from_string.
W@buf:Array<U32> -> @cap:U32 -> @n:U32 -> @w:U32 -> W
type Sb source · line 166 · raw
Type
BValue@i:U32 -> @stack:List<&1, Open> -> Sb
BFirst@i:U32 -> @open:Open -> @stack:List<&1, Open> -> Sb
BKey@i:U32 -> @stack:List<&1, Open> -> Sb
BColon@key:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> @i:U32 -> @stack:List<&1, Open> -> Sb
BStr@i:U32 -> @start:U32 -> @key:Bool -> @stack:List<&1, Open> -> Sb
BEsc@i:U32 -> @acc:W -> @key:Bool -> @stack:List<&1, Open> -> Sb
BNum@i:U32 -> @start:U32 -> @st:U32 -> @stack:List<&1, Open> -> Sb
BAfter@v:Val -> @i:U32 -> @stack:List<&1, Open> -> Sb
BSep@i:U32 -> @open:Open -> @stack:List<&1, Open> -> Sb
BEnd@v:Val -> @i:U32 -> Sb
BOk@v:Val -> Sb
BFailSb
type Cp source · line 180 · raw
Data
Cp@c:U32 -> @w:U32 -> Cp
Definitions
def w.room source · line 36 · raw
@grow:Bool -> @buf:Array<U32> -> @+k:U32 -> Array<U32>
The buffer doubles when word k does not fit.
def w.store source · line 43 · raw
@full:Bool -> @buf:Array<U32> -> @+cap:U32 -> @+n:U32 -> @+w:U32 -> W
def w.put source · line 52 · raw
@o:W -> @+b:U32 -> W
def w.shrink source · line 56 · raw
@fit:Bool -> @+n:U32 -> @buf:Array<U32> -> Array<U32>
def w.done source · line 64 · raw
@o:W -> 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes
Stores the last partial word, then copies into the fewest words, as Bytes requires.
def w.cont source · line 73 · raw
@+c:U32 -> @+k:Nat -> U32
def w.cp.of source · line 76 · raw
@+n:U32 -> @+c:U32 -> @o:W -> W
def w.cp source · line 88 · raw
@+c:U32 -> @o:W -> W
One code point in UTF-8.
def w.hex source · line 91 · raw
@+n:U32 -> U32
def w.new source · line 94 · raw
W
def w.of.at source · line 97 · raw
@+len:U32 -> @+cap:U32 -> @r:Pair(Array<U32>, U32) -> W
def w.of source · line 103 · raw
@b:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> W
A writer that appends to b.
def w.text source · line 107 · raw
@s:String -> @o:W -> W
def utf8 source · line 115 · raw
@s:String -> 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes
Text, one Char per code point, as UTF-8.
def digit source · line 124 · raw
@+c:U32 -> Bool
def num.trans source · line 127 · raw
@+st:U32 -> @+c:U32 -> U32
def num.accepts source · line 140 · raw
@+st:U32 -> Bool
def hexd source · line 146 · raw
@+c:U32 -> U32
def is_hi source · line 149 · raw
@+v:U32 -> Bool
def is_lo source · line 152 · raw
@+v:U32 -> Bool
def esc.simple source · line 155 · raw
@+e:U32 -> U32
def pk.if source · line 183 · raw
@ok:Bool -> @a:Array<U32> -> @+i:U32 -> Pair(Array<U32>, U32)
def pk source · line 191 · raw
@a:Array<U32> -> @+len:U32 -> @+i:U32 -> Pair(Array<U32>, U32)
Byte i, or 256 at the end, which no rule accepts.
def is_ws source · line 194 · raw
@+c:U32 -> Bool
def plain source · line 198 · raw
@+c:U32 -> Bool
A string byte that needs no check: ASCII, not a control, quote or backslash.
def pos.of source · line 201 · raw
@+i:U32 -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Pair(U32, U32))
def pos source · line 206 · raw
@a:Array<U32> -> @+len:U32 -> @+i:U32 -> Pair(Array<U32>, Pair(U32, U32))
The offset i and its byte.
def word.go source · line 231 · raw
@w:String -> @ok:Bool -> @r:Pair(Array<U32>, U32) -> @+len:U32 -> @+j:U32 -> Pair(Array<U32>, Bool)
def word source · line 241 · raw
@a:Array<U32> -> @+len:U32 -> @w:String -> @+j:U32 -> Pair(Array<U32>, Bool)
Do the bytes from j spell w?
def hex4.b.go source · line 244 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @+len:U32 -> @+j:U32 -> @+acc:U32 -> Pair(Array<U32>, U32)
def hex4.b source · line 255 · raw
@a:Array<U32> -> @+len:U32 -> @+j:U32 -> Pair(Array<U32>, U32)
Four hex digits from byte j, or 65536 if one is not a hex digit.
def cont source · line 258 · raw
@+b:U32 -> Bool
def utf8.n source · line 262 · raw
@+b0:U32 -> @+b1:U32 -> @+b2:U32 -> @+b3:U32 -> Cp
RFC 3629 §4: overlong forms, surrogates, and code points past U+10FFFF are invalid, width 0.
def utf8.b3 source · line 274 · raw
@+b0:U32 -> @+b1:U32 -> @+b2:U32 -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Cp)
def utf8.b2 source · line 278 · raw
@+len:U32 -> @+i:U32 -> @+b0:U32 -> @+b1:U32 -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Cp)
def utf8.b1 source · line 282 · raw
@+len:U32 -> @+i:U32 -> @+b0:U32 -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Cp)
def utf8.at source · line 287 · raw
@a:Array<U32> -> @+len:U32 -> @+i:U32 -> @+b0:U32 -> Pair(Array<U32>, Cp)
The code point whose lead byte b0 is at i.
def slice.of source · line 290 · raw
@+n:U32 -> @r:Pair(Array<U32>, Array<U32>) -> Pair(Array<U32>, 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes)
def slice source · line 295 · raw
@+n:U32 -> @+start:U32 -> @a:Array<U32> -> Pair(Array<U32>, 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes)
The n bytes from start, copied.
def str.b.done source · line 298 · raw
@key:Bool -> @s:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> @+i:U32 -> @stack:List<&1, Open> -> Sb
def esc.b.lone source · line 305 · raw
@strict:Bool -> @+i:U32 -> @acc:W -> @key:Bool -> @stack:List<&1, Open> -> Sb
def esc.b.lo.if source · line 312 · raw
@ok:Bool -> @strict:Bool -> @+i:U32 -> @+hi:U32 -> @+lo:U32 -> @acc:W -> @key:Bool -> @stack:List<&1, Open> -> Sb
def esc.b.lo source · line 319 · raw
@strict:Bool -> @+i:U32 -> @+hi:U32 -> @acc:W -> @key:Bool -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Sb)
def esc.b.pair source · line 324 · raw
@+strict:Bool -> @+len:U32 -> @+i:U32 -> @+hi:U32 -> @acc:W -> @key:Bool -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, Bool) -> Pair(Array<U32>, Sb)
A high surrogate must pair in strict mode; RFC §8.2 mode replaces a lone one.
def u.class source · line 333 · raw
@+v:U32 -> U32
0: not four hex digits; 1: high surrogate; 2: low surrogate; 3: other.
def esc.b.u.of source · line 336 · raw
@+k:U32 -> @strict:Bool -> @a:Array<U32> -> @+len:U32 -> @+i:U32 -> @+v:U32 -> @acc:W -> @key:Bool -> @stack:List<&1, Open> -> Pair(Array<U32>, Sb)
def esc.b.u source · line 347 · raw
@strict:Bool -> @+len:U32 -> @+i:U32 -> @acc:W -> @key:Bool -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Sb)
def esc.b.one source · line 352 · raw
@strict:Bool -> @+len:U32 -> @+i:U32 -> @acc:W -> @key:Bool -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Sb)
The escape whose backslash is at i.
def esc.b.cp source · line 361 · raw
@acc:W -> @key:Bool -> @stack:List<&1, Open> -> @+i:U32 -> @r:Pair(Array<U32>, Cp) -> Pair(Array<U32>, Sb)
def esc.b.other source · line 366 · raw
@ascii:Bool -> @+c:U32 -> @a:Array<U32> -> @+len:U32 -> @+i:U32 -> @acc:W -> @key:Bool -> @stack:List<&1, Open> -> Pair(Array<U32>, Sb)
§7: unescaped chars below U+0020 are not allowed in a string.
def esc.b source · line 374 · raw
@strict:Bool -> @r:Pair(Array<U32>, U32) -> @+len:U32 -> @+i:U32 -> @acc:W -> @key:Bool -> @stack:List<&1, Open> -> Pair(Array<U32>, Sb)
A string after its first escape.
def str.b.close source · line 386 · raw
@key:Bool -> @+i:U32 -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes) -> Pair(Array<U32>, Sb)
def str.b.esc source · line 390 · raw
@strict:Bool -> @+len:U32 -> @+i:U32 -> @key:Bool -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes) -> Pair(Array<U32>, Sb)
def str.b.cp source · line 394 · raw
@+start:U32 -> @key:Bool -> @stack:List<&1, Open> -> @+i:U32 -> @r:Pair(Array<U32>, Cp) -> Pair(Array<U32>, Sb)
def str.b.other source · line 398 · raw
@ascii:Bool -> @+c:U32 -> @a:Array<U32> -> @+len:U32 -> @+i:U32 -> @+start:U32 -> @key:Bool -> @stack:List<&1, Open> -> Pair(Array<U32>, Sb)
def str.b source · line 406 · raw
@strict:Bool -> @r:Pair(Array<U32>, U32) -> @+len:U32 -> @+i:U32 -> @+start:U32 -> @key:Bool -> @stack:List<&1, Open> -> Pair(Array<U32>, Sb)
A string whose text so far starts at start and has no escape.
def num.b.fin source · line 418 · raw
@+i:U32 -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes) -> Pair(Array<U32>, Sb)
def num.b.stop source · line 422 · raw
@ok:Bool -> @a:Array<U32> -> @+i:U32 -> @+start:U32 -> @stack:List<&1, Open> -> Pair(Array<U32>, Sb)
def num.b.if source · line 429 · raw
@stop:Bool -> @a:Array<U32> -> @+i:U32 -> @+start:U32 -> @+st:U32 -> @+n:U32 -> @stack:List<&1, Open> -> Pair(Array<U32>, Sb)
def num.b source · line 436 · raw
@r:Pair(Array<U32>, U32) -> @+i:U32 -> @+start:U32 -> @+st:U32 -> @stack:List<&1, Open> -> Pair(Array<U32>, Sb)
def lit.b source · line 441 · raw
@+i:U32 -> @+n:U32 -> @v:Val -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, Bool) -> Pair(Array<U32>, Sb)
def value.b source · line 449 · raw
@r:Pair(Array<U32>, U32) -> @+len:U32 -> @+i:U32 -> @stack:List<&1, Open> -> Pair(Array<U32>, Sb)
def first.b.end source · line 476 · raw
@open:Open -> @+c:U32 -> @+i:U32 -> @stack:List<&1, Open> -> Sb
After "[" or "{": the closing bracket, or the first item.
def first.b.open source · line 485 · raw
@open:Open -> @+i:U32 -> @stack:List<&1, Open> -> Sb
def first.b source · line 494 · raw
@r:Pair(Array<U32>, U32) -> @+i:U32 -> @open:Open -> @stack:List<&1, Open> -> Pair(Array<U32>, Sb)
def key.b source · line 512 · raw
@r:Pair(Array<U32>, U32) -> @+i:U32 -> @stack:List<&1, Open> -> Pair(Array<U32>, Sb)
def colon.b.top source · line 528 · raw
@k:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> @+i:U32 -> @stack:List<&1, Open> -> Sb
def colon.b source · line 539 · raw
@r:Pair(Array<U32>, U32) -> @k:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> @+i:U32 -> @stack:List<&1, Open> -> Pair(Array<U32>, Sb)
def after.b source · line 556 · raw
@v:Val -> @+i:U32 -> @stack:List<&1, Open> -> Sb
A finished value joins its container.
def sep.b.comma source · line 567 · raw
@open:Open -> @+i:U32 -> @up:List<&1, Open> -> Sb
def sep.b.close source · line 576 · raw
@open:Open -> @+c:U32 -> @+i:U32 -> @up:List<&1, Open> -> Sb
def sep.b source · line 586 · raw
@r:Pair(Array<U32>, U32) -> @+i:U32 -> @open:Open -> @up:List<&1, Open> -> Pair(Array<U32>, Sb)
After an item: "," or the closing bracket.
def end.b source · line 602 · raw
@r:Pair(Array<U32>, U32) -> @v:Val -> @+i:U32 -> Pair(Array<U32>, Sb)
def value.r source · line 619 · raw
@+len:U32 -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, Pair(U32, U32)) -> Pair(Array<U32>, Sb)
A run's end (a, i, c) to each step. The parts bind without + (bendlang/bend#1077).
def level.r source · line 623 · raw
@depth:U32 -> @r:Pair(Array<U32>, Sb) -> Pair(Array<U32>, Pair(Sb, U32))
def first.at source · line 627 · raw
@a:Array<U32> -> @+c:U32 -> @i:U32 -> @+depth:U32 -> @open:Open -> @stack:List<&1, Open> -> Pair(Array<U32>, Pair(Sb, U32))
def first.r source · line 630 · raw
@ok:Bool -> @+depth:U32 -> @open:Open -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, Pair(U32, U32)) -> Pair(Array<U32>, Pair(Sb, U32))
def first.limit source · line 639 · raw
@cap:U32 -> @+depth:U32 -> @open:Open -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, Pair(U32, U32)) -> Pair(Array<U32>, Pair(Sb, U32))
def key.r source · line 642 · raw
@stack:List<&1, Open> -> @r:Pair(Array<U32>, Pair(U32, U32)) -> Pair(Array<U32>, Sb)
def colon.r source · line 646 · raw
@k:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, Pair(U32, U32)) -> Pair(Array<U32>, Sb)
def str.r source · line 650 · raw
@strict:Bool -> @+len:U32 -> @+s:U32 -> @key:Bool -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, Pair(U32, U32)) -> Pair(Array<U32>, Sb)
def num.r source · line 654 · raw
@+s:U32 -> @+st:U32 -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, Pair(U32, U32)) -> Pair(Array<U32>, Sb)
def sep.at source · line 658 · raw
@a:Array<U32> -> @+c:U32 -> @i:U32 -> @+depth:U32 -> @open:Open -> @up:List<&1, Open> -> Pair(Array<U32>, Pair(Sb, U32))
def sep.r source · line 661 · raw
@+depth:U32 -> @open:Open -> @up:List<&1, Open> -> @r:Pair(Array<U32>, Pair(U32, U32)) -> Pair(Array<U32>, Pair(Sb, U32))
def end.r source · line 665 · raw
@v:Val -> @r:Pair(Array<U32>, Pair(U32, U32)) -> Pair(Array<U32>, Sb)
def w.span.go source · line 669 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @+i:U32 -> @o:W -> Pair(Array<U32>, W)
def esc.r.go source · line 678 · raw
@strict:Bool -> @+len:U32 -> @+j:U32 -> @c:U32 -> @key:Bool -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, W) -> Pair(Array<U32>, Sb)
def esc.r source · line 683 · raw
@strict:Bool -> @+len:U32 -> @+i:U32 -> @acc:W -> @key:Bool -> @stack:List<&1, Open> -> @r:Pair(Array<U32>, Pair(U32, U32)) -> Pair(Array<U32>, Sb)
The plain bytes from i to the run's end go onto acc in one loop.
def num.run source · line 688 · raw
@loop:Bool -> @+g:Nat -> @a:Array<U32> -> @+len:U32 -> @+i:U32 -> Pair(Array<U32>, Pair(U32, U32))
States 3, 5 and 8 take digits until the number's part ends.
def runb source · line 696 · raw
@+fuel:Nat -> @r:Pair(Array<U32>, Pair(Sb, U32)) -> @+len:U32 -> @+strict:Bool -> @+cap:U32 -> Maybe<&1, Val>
fuel: a step eats a byte, or ends a number, a value, or an opening bracket, so 4 * len + 4 steps are enough.
def parse.bytes source · line 729 · raw
@b:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> Maybe<&1, Val>
One JSON text in UTF-8, with RFC §8.2 surrogate replacement and input-sized depth.
def parse.strict.bytes source · line 736 · raw
@b:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> @cap:U32 -> Maybe<&1, Val>
Strict UTF-8 JSON: reject lone surrogate escapes and more than cap nested arrays/objects, including empty containers. Scalars have depth zero. The limit is checked at each opening, before any contents are parsed.
def unique.print.go source · line 747 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @+i:U32 -> @acc:List<&2, U32> -> Pair(Array<U32>, List<&2, U32>)
Reads from the last word down and prepends, so acc ends in index order.
def unique.print.fin source · line 756 · raw
@+len:U32 -> @r:Pair(Array<U32>, List<&2, U32>) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, List<&2, U32>)
def unique.print source · line 762 · raw
@k:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, List<&2, U32>)
The key back, and its fingerprint: the length, then its words. Bytes past the length are 0, so two keys are equal exactly when their fingerprints are.
def unique.le source · line 769 · raw
@a:List<&2, U32> -> @b:List<&2, U32> -> Bool
Lexicographic order on fingerprints.
def unique.distinct source · line 781 · raw
@xs:List<&2, List<&2, U32>> -> @+prev:List<&2, U32> -> Bool
xs is sorted and prev <= each of xs, so prev equals x when x <= prev.
def unique.sorted source · line 788 · raw
@xs:List<&2, List<&2, U32>> -> Bool
def unique.check source · line 796 · raw
@keys:List<&2, List<&2, U32>> -> Bool
Whether one object's fingerprints are pairwise distinct.
def unique.array.tail source · line 799 · raw
@tail:Val -> @head:Val -> @ok:Bool -> Pair(Val, Pair(Bool, List<&2, List<&2, U32>>))
def unique.array source · line 806 · raw
@head_result:Pair(Val, Pair(Bool, List<&2, List<&2, U32>>)) -> @tail_result:Pair(Val, Pair(Bool, List<&2, List<&2, U32>>)) -> Pair(Val, Pair(Bool, List<&2, List<&2, U32>>))
def unique.object.done source · line 811 · raw
@print:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, List<&2, U32>) -> @head:Val -> @kvs:List<&1, Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, Val)> -> @ok:Bool -> @keys:List<&2, List<&2, U32>> -> Pair(Val, Pair(Bool, List<&2, List<&2, U32>>))
def unique.object.tail source · line 815 · raw
@tail:Val -> @key:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> @head:Val -> @ok:Bool -> @keys:List<&2, List<&2, U32>> -> Pair(Val, Pair(Bool, List<&2, List<&2, U32>>))
def unique.object source · line 822 · raw
@key:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> @head_result:Pair(Val, Pair(Bool, List<&2, List<&2, U32>>)) -> @tail_result:Pair(Val, Pair(Bool, List<&2, List<&2, U32>>)) -> Pair(Val, Pair(Bool, List<&2, List<&2, U32>>))
def unique.go source · line 830 · raw
@v:Val -> Pair(Val, Pair(Bool, List<&2, List<&2, U32>>))
The value back, whether every object nested inside it has unique keys, and the fingerprints of v's own keys when v is an object. The caller that holds the whole object checks those.
def unique.keys.fin source · line 849 · raw
@r:Pair(Val, Pair(Bool, List<&2, List<&2, U32>>)) -> Pair(Val, Bool)
def unique.keys source · line 855 · raw
@v:Val -> Pair(Val, Bool)
Returns the value and whether every object's decoded keys are unique. This predicate checks keys. Syntax and depth limits belong to the parser.
def unique.answer source · line 858 · raw
@r:Pair(Val, Bool) -> Maybe<&1, Val>
def unique.parsed source · line 866 · raw
@r:Maybe<&1, Val> -> Maybe<&1, Val>
def parse.strict.unique.bytes source · line 874 · raw
@b:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> @cap:U32 -> Maybe<&1, Val>
Strict UTF-8 JSON with the caller's depth cap and unique decoded object keys.
def get.pick source · line 880 · raw
@v:Val -> @found:Maybe<&1, Val> -> @r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, Bool)) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, Maybe<&1, Val>)
def get.step source · line 884 · raw
@k:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> @v:Val -> @st:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, Maybe<&1, Val>) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, Maybe<&1, Val>)
def get.go source · line 888 · raw
@kvs:List<&1, Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, Val)> -> @st:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, Maybe<&1, Val>) -> Maybe<&1, Val>
def get source · line 897 · raw
@v:Val -> @k:String -> Maybe<&1, Val>
§4: the value under key k of an object; the last one when k repeats, as most parsers do.
def at.go source · line 912 · raw
@xs:List<&1, Val> -> @n:Nat -> Maybe<&1, Val>
def at source · line 924 · raw
@v:Val -> @n:Nat -> Maybe<&1, Val>
Item n of an array.
def u32.over source · line 939 · raw
@+acc:U32 -> @+c:U32 -> Bool
def u32.dig source · line 942 · raw
@s:String -> @+acc:U32 -> @bad:Bool -> Maybe<&2, U32>
def u32.zero source · line 953 · raw
@t:String -> Maybe<&2, U32>
def u32.lead source · line 960 · raw
@+c:U32 -> @t:String -> @zero:Bool -> Maybe<&2, U32>
def u32.num source · line 967 · raw
@s:String -> Maybe<&2, U32>
def u32 source · line 975 · raw
@v:Val -> Maybe<&2, U32>
A number that is a whole U32, with no sign, fraction or exponent.
def f32 source · line 991 · raw
@v:Val -> Maybe<&2, F32>
The nearest F32 to a number, with Base F32.read.
def f64 source · line 1007 · raw
@v:Val -> Maybe<&2, 0x5eb40ff91b54d04ca8d44189421891b9/f64.F64>
The nearest F64 to a number, with F64.read from bend-kit-f64.
def w.ctl source · line 1025 · raw
@ctl:Bool -> @+c:U32 -> @o:W -> W
def w.esc.c source · line 1033 · raw
@+c:U32 -> @o:W -> W
§7: quote, backslash and control chars are escaped. Other bytes are already UTF-8.
def w.bytes.go source · line 1048 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @+i:U32 -> @o:W -> W
def w.bytes source · line 1056 · raw
@b:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> @o:W -> W
def w.str.go source · line 1060 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @+i:U32 -> @o:W -> W
def w.str source · line 1069 · raw
@b:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> @o:W -> W
A quoted, escaped string.
def w.lead source · line 1074 · raw
@open:Bool -> @+c:U32 -> @o:W -> W
open: the container's first byte comes next; else a comma or its last byte.
def w.close source · line 1081 · raw
@open:Bool -> @+a:U32 -> @+z:U32 -> @o:W -> W
def encb.go source · line 1088 · raw
@v:Val -> @open:Bool -> @o:W -> W
def encode.bytes source · line 1116 · raw
@v:Val -> 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes
Compact JSON in UTF-8, with object fields in their order.
Templates
template run.cls source · line 209 · raw
@-ok:(@+c:U32 -> Bool) -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Pair(U32, Bool))
template run.go source · line 214 · raw
@-ok:(@+c:U32 -> Bool) -> @g:Nat -> @r:Pair(Array<U32>, Pair(U32, Bool)) -> @+len:U32 -> @+i:U32 -> Pair(Array<U32>, Pair(U32, U32))
g bounds the loop; it is the parser's fuel, shared, so no count is built per run.
template run source · line 228 · raw
@-ok:(@+c:U32 -> Bool) -> @+g:Nat -> @a:Array<U32> -> @+len:U32 -> @+i:U32 -> Pair(Array<U32>, Pair(U32, U32))
The first offset from i whose byte is not ok, and that byte.