~/bend-docscommunity

main.bend checks

raw source on the hub · import 0xa3c2445eb44c5d8406e6229be518fccb/main.bend as Main

ezjson: JSON for Bend 2. parse turns text into Maybe Json; print writes compact text. Build with obj, arr, and num; read with get, str_or, and u32_or. Constructors of Json live in ./value.bend.

4 imports
import Base
import ./value.bend as Value
import ./parse.bend as Parse
import ./print.bend as Print

Definitions

def parse source · line 10 · raw

@s:String -> Maybe<&2, 0xa3c2445eb44c5d8406e6229be518fccb/value.Json>

a text as a value, or None when it is not JSON

@j:0xa3c2445eb44c5d8406e6229be518fccb/value.Json -> String

a value as compact JSON

def obj source · line 18 · raw

@pairs:List<&1, Pair(String, 0xa3c2445eb44c5d8406e6229be518fccb/value.Json)> -> 0xa3c2445eb44c5d8406e6229be518fccb/value.Json

an object from pairs

def arr source · line 22 · raw

@items:List<&2, 0xa3c2445eb44c5d8406e6229be518fccb/value.Json> -> 0xa3c2445eb44c5d8406e6229be518fccb/value.Json

an array from a list

def num source · line 26 · raw

@n:U32 -> 0xa3c2445eb44c5d8406e6229be518fccb/value.Json

a number

def get source · line 31 · raw

@j:0xa3c2445eb44c5d8406e6229be518fccb/value.Json -> @key:String -> 0xa3c2445eb44c5d8406e6229be518fccb/value.Json

an object's value at a key; JNull when it is not an object or has no such key

def str_or source · line 35 · raw

@j:0xa3c2445eb44c5d8406e6229be518fccb/value.Json -> @default:String -> String

a string's text, else the default

def u32_or source · line 39 · raw

@j:0xa3c2445eb44c5d8406e6229be518fccb/value.Json -> @default:U32 -> U32

a number as a U32, else the default