def parse.json

bend-kit-jwt@0.11.0.1 · jwt.bend:258

import bend-kit-jwt@0.11.0.1/jwt.bend as Jwt
import Base
import bend-kit-json@0.7.0.0/json.bend as Json
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

258# RFC 7515 §5.2 allows rejecting repeated names; a second "alg" is how parsers come to disagree.
259# parse.claims rejects them at every depth with Json.unique.parsed before members get here.
260def parse.json(h: Maybe<&1, Json.Val>, f: Maybe<&1, Json.Val>, c: Maybe<&1, Json.Val>, input: Bytes.Bytes, sig: Bytes.Bytes) ->
261    Result<&1, &1, Err, Parts>:
262  match h f c:
263    case Some{Json.Obj{hk}} Some{Json.Obj{fk}} Some{cv}:
264      Done{Parts{fields(hk, Nil{}), fields(fk, Nil{}), cv, input, sig}}
265    case _ _ _:
266      Fail{Malformed{}}

Uses (8)

Used by (1)