roc/crates/compiler/uitest/tests/solve/stdlib_encode_json.txt
2023-06-08 19:34:52 +10:00

18 lines
413 B
Text

app "test"
imports [TotallyNotJson]
provides [main] to "./platform"
HelloWorld := {} has [Encoding {toEncoder}]
toEncoder = \@HelloWorld {} ->
Encode.custom \bytes, fmt ->
bytes
|> Encode.appendWith (Encode.string "Hello, World!\n") fmt
f =
when Str.fromUtf8 (Encode.toBytes (@HelloWorld {}) TotallyNotJson.json) is
Ok s -> s
_ -> "<bad>"
main = f
# ^ Str