mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-10 10:02:38 +03:00
Add an example for deeply nested record decoding
This commit is contained in:
parent
0d763518f1
commit
abdc0d5689
@ -1010,3 +1010,22 @@ fn decode_empty_record() {
|
||||
RocStr
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn decode_record_of_record() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" imports [Encode, Decode, Json] provides [main] to "./platform"
|
||||
|
||||
main =
|
||||
when Str.toUtf8 "{\"outer\":{\"inner\":\"a\"},\"other\":{\"one\":\"b\",\"two\":10}}" |> Decode.fromBytes Json.fromUtf8 is
|
||||
Ok {outer: {inner: "a"}, other: {one: "b", two: 10u8}} -> "ab10"
|
||||
_ -> "something went wrong"
|
||||
"#
|
||||
),
|
||||
RocStr::from("ab10"),
|
||||
RocStr
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user