RoundTripNestedTest
`Json.Decode.at [ "a", "b" ]` reads the integer 42 from an object nested inside another object.
Results
elm-0.19.1
passran in 45 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. rt_nested: Ok 42
elm-0.19.2
passran in 57 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. rt_nested: Ok 42
elm-0.19.3
passran in 58 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. rt_nested: Ok 42
lamdera-1.5.0
passran in 49 msOutput
rt_nested: Ok 42
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-json/RoundTripNestedTest] in its title.
Source
The -- CHECK: lines give the expected output.
module RoundTripNestedTest exposing (main)
{-| `Json.Decode.at [ "a", "b" ]` reads the integer 42 from an object nested inside another object.
-}
-- CHECK: rt_nested: Ok 42
import Html exposing (text)
import Json.Decode as Decode
import Json.Encode as Encode
main =
let
json = Encode.encode 0 (Encode.object [ ( "a", Encode.object [ ( "b", Encode.int 42 ) ] ) ])
_ = Debug.log "rt_nested" (Decode.decodeString (Decode.at [ "a", "b" ] Decode.int) json)
in
text "done"