EncodeEmptyStringTest
`Json.Encode.string ""` encodes to the two-character JSON text `""`, and decoding that with `Json.Decode.string` gives back the empty string.
Results
elm-0.19.1
passran in 65 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. encoded: "\"\"" encoded_len: 2 decoded: Ok ""
elm-0.19.2
passran in 64 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. encoded: "\"\"" encoded_len: 2 decoded: Ok ""
elm-0.19.3
passran in 64 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. encoded: "\"\"" encoded_len: 2 decoded: Ok ""
lamdera-1.5.0
passran in 64 msOutput
encoded: "\"\"" encoded_len: 2 decoded: Ok ""
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-json/EncodeEmptyStringTest] in its title.
Source
The -- CHECK: lines give the expected output.
module EncodeEmptyStringTest exposing (main)
{-| `Json.Encode.string ""` encodes to the two-character JSON text `""`, and decoding that
with `Json.Decode.string` gives back the empty string.
-}
-- CHECK: encoded: "\"\""
-- CHECK: encoded_len: 2
-- CHECK: decoded: Ok ""
import Html exposing (text)
import Json.Decode as Decode
import Json.Encode as Encode
main =
let
encoded =
Encode.encode 0 (Encode.string "")
_ =
Debug.log "encoded" encoded
_ =
Debug.log "encoded_len" (String.length encoded)
_ =
Debug.log "decoded" (Decode.decodeString Decode.string encoded)
in
text "done"