def to_toon

cswap-bend-cli@0.1.0.0 · fmt/toon.bend:10

import cswap-bend-cli@0.1.0.0/fmt/toon.bend as Toon
import Base
import cswap-bend-cli@0.1.0.0/json.bend as Json
import bend-toon-codec@0.1.0.0/main.bend as Toon

10def to_toon(j: Json.Json) -> Toon.Json:
11  match j:
12    case Json.JNull{}:
13      Toon.JNull{}
14    case Json.JBool{b}:
15      Toon.JBool{b}
16    case Json.JNum{t}:
17      Toon.JNum{t}
18    case Json.JStr{s}:
19      Toon.JStr{s}
20    case Json.JArr{x}:
21      Toon.JArr{to_toon(x)}
22    case Json.JObj{x}:
23      Toon.JObj{to_toon(x)}
24    case Json.JNil{}:
25      Toon.JNil{}
26    case Json.JCons{h, t}:
27      Toon.JCons{to_toon(h), to_toon(t)}
28    case Json.JField{k, v, t}:
29      Toon.JField{k, to_toon(v), to_toon(t)}

Uses (2)

Used by (1)