I have the following Type called Message with the following code
module Types.Message exposing (Message, decode, decodeList)
import Json.Decode as Decode exposing (Decoder, Error, list)
import Json.Decode.Pipeline exposing (required)
type alias Message =
{ username : String
, content : String
}
decode : Decoder Message
decode =
Decode.succeed Message
|> required "username" Decode.string
|> required "content" Decode.string
decodeList : Decoder (List Message)
decodeList =
list decode
I try to decode using something like this
decodeMessage : Decode.Value -> Result Error (List Message)
decodeMessage messageJson =
Decode.decodeValue
Message.decodeList
messageJson
I found out that it works perfectly in REPL
> decodeString decode "{\"username\": \"mantap\", \"content\": \"lalui\"}"
Ok { content = "lalui", username = "mantap" }
: Result Error Message
However, when I run the Webpack build using the elm-webpack-loader in Electron environment I found the following error
Problem with the value at json[0]: "{\"content\": \"Budi\", \"username\": \"UHU\"}" Expecting an OBJECT with a field named `content`
Any idea why?
I have the following Type called
Messagewith the following codeI try to decode using something like this
I found out that it works perfectly in REPL
However, when I run the Webpack build using the
elm-webpack-loaderin Electron environment I found the following errorAny idea why?