def fields
import bendonnect-rpc@0.1.0.0/src/pbjson.bend as Pbjsonimport Base
import bend-kit-json@0.6.1.1/json.bend as Json
362# The entries of a JSON object, keys decoded. A non-object (including null) is an error;
363# for singular message fields test for null first with Pj.read.opt.
364def fields(v: Json.Val) -> Result<&2, &1, String, List<&1, String & Json.Val>>:
365 match v:
366 case Json.Obj{kvs}:
367 Done{fields.go(kvs)}
368 case Json.Null{}:
369 Fail{"expected a JSON object, got null"}
370 case Json.Flag{on}:
371 Fail{"expected a JSON object, got a boolean"}
372 case Json.Num{s}:
373 Fail{"expected a JSON object, got a number"}
374 case Json.Str{s}:
375 Fail{"expected a JSON object, got a string"}
376 case Json.Arr{xs}:
377 Fail{"expected a JSON object, got an array"}
Uses (6)
Used by (0)
No other definition uses this definition.