def source

qasim-bend-kit@0.1.0.2 · libs/JSON.bend:1036

import qasim-bend-kit@0.1.0.2/libs/JSON.bend as JSON
import Base

1036def source(value: Value, members: BoolType(), acc: List<&2, Lexeme>) -> List<&2, Lexeme>:
1037    match value:
1038        case Null{}: source_text("null", acc)
1039        case Bool{truth}:
1040            match truth:
1041                case True{}: source_text("true", acc)
1042                case False{}: source_text("false", acc)
1043        case Number{lexeme, certificate}: source_text(lexeme, acc)
1044        case Str{text}: source_text("\"" ++ escape_string(text) ++ "\"", acc)
1045        case Arr{Nil{}}:
1046            match members:
1047                case False{}: Punctuation{'['} <> Punctuation{']'} <> acc
1048                case True{}: Punctuation{']'} <> acc
1049        case Arr{head <> tail}:
1050            match members:
1051                case False{}: Punctuation{'['} <> source(head, False{}, source(Arr{tail}, True{}, acc))
1052                case True{}: Punctuation{','} <> source(head, False{}, source(Arr{tail}, True{}, acc))
1053        case Obj{Nil{}}:
1054            match members:
1055                case False{}: Punctuation{'{'} <> Punctuation{'}'} <> acc
1056                case True{}: Punctuation{'}'} <> acc
1057        case Obj{(key, value) <> tail}:
1058            match members:
1059                case False{}: Punctuation{'{'} <> source_text("\"" ++ escape_string(key) ++ "\"", Punctuation{':'} <> source(value, False{}, source(Obj{tail}, True{}, acc)))
1060                case True{}: Punctuation{','} <> source_text("\"" ++ escape_string(key) ++ "\"", Punctuation{':'} <> source(value, False{}, source(Obj{tail}, True{}, acc)))

Uses (10)

Used by (26)