def print
emerging-ezjson@1.3.0.0 · src/print.bend:70
import emerging-ezjson@1.3.0.0/src/print.bend as Print
import Base
import emerging-ezjson@1.3.0.0/src/value.bend as V
70
71def print(val: V.Json) -> String:
72 match val:
73 case V.JNull{}:
74 "null"
75 case V.JBool{True{}}:
76 "true"
77 case V.JBool{False{}}:
78 "false"
79 case V.JNum{raw}:
80 raw
81 case V.JStr{s}:
82 quote(s)
83 case V.JSpan{src, +n}:
84 quote(V.span.str(src, n, U32.is_zero(n)))
85 case V.JArr{items}:
86 "[" ++ print(items) ++ "]"
87 case V.JObj{pairs}:
88 "{" ++ print(pairs) ++ "}"
89 case V.JNil{}:
90 ""
91 case V.JCons{h, V.JNil{}}:
92 print(h)
93 case V.JCons{h, t}:
94 print(h) ++ "," ++ print(t)
95 case V.JPair{k, v, V.JNil{}}:
96 quote(k) ++ ":" ++ print(v)
97 case V.JPair{k, v, r}:
98 quote(k) ++ ":" ++ print(v) ++ "," ++ print(r)
99 case V.JBind{src, +n, v, V.JNil{}}:
100 quote(V.span.str(src, n, U32.is_zero(n))) ++ ":" ++ print(v)
101 case V.JBind{src, +n, v, r}:
102 quote(V.span.str(src, n, U32.is_zero(n))) ++ ":" ++ print(v) ++ "," ++ print(r)