src/JsonAdapter.bend relies on unsafe/foreign
raw source on the hub · import ber-core-store@0.1.2.0/src/JsonAdapter.bend as JsonAdapter
2 imports
import Base import bend-kit-json@0.3.0.0/json.bend as Json
Definitions
def make_str source · line 15 · raw
@+text:String -> 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val
Wraps text as a JSON string value.
def make_arr source · line 19 · raw
@items:List<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val
Wraps a value list as a JSON array.
def make_kv source · line 23 · raw
@+field_key:String -> @field_value:0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val -> Sigma<&2, &2, String, _ => 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val>
Builds one object field pair.
def fold_pair source · line 27 · raw
@field_map:Map<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> @field_pair:Sigma<&2, &2, String, _ => 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> Map<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val>
Inserts one field pair into the map.
def fold_fields source · line 33 · raw
@remaining_fields:List<&2, Sigma<&2, &2, String, _ => 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val>> -> @field_map:Map<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val> -> Map<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val>
Folds a field list into a map; the list shrinks first.
def make_obj source · line 41 · raw
@fields:List<&2, Sigma<&2, &2, String, _ => 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val>> -> 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val
Builds an object; keys come out sorted by construction.
def parse_text source · line 45 · raw
@+stored_text:String -> Maybe<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val>
Parses stored text; None on malformed input.
def get_field source · line 49 · raw
@+document:0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val -> @+field_name:String -> Maybe<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val>
Looks up an object field; None when absent or not an object.
def as_str source · line 53 · raw
@json_value:0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val -> Maybe<&2, String>
Unwraps a string value; None otherwise.
def as_arr source · line 61 · raw
@json_value:0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val -> Maybe<&2, List<&2, 0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val>>
Unwraps an array value; None otherwise.
def encode_canonical source · line 69 · raw
@+document:0xaaa10a97bf5ac6990143da2c863f8a3f/json.Val -> String
Encodes with keys sorted; the canonical bytes.