I have this situation
-- this is in post.elm
type alias Model =
{ img : String
, text : String
, source : String
, date : String
, comments : Comments.Model
}
-- this is in comments.elm
type alias Model =
List Comment.Model
-- this is in comment.elm
type alias Model =
{ text : String
, date : String
}
I am trying to parse a JSON so formed
{
"posts": [{
"img": "img 1",
"text": "text 1",
"source": "source 1",
"date": "date 1",
"comments": [{
"text": "comment text 1 1",
"date": "comment date 1 1"
}]
}
}
This is my Decoder
decoder : Decoder Post.Model
decoder =
Decode.object5
Post.Model
("img" := Decode.string)
("text" := Decode.string)
("source" := Decode.string)
("date" := Decode.string)
("comments" := Decode.list Comments.Model)
decoderColl : Decoder Model
decoderColl =
Decode.object1
identity
("posts" := Decode.list decoder)
It does not work, I am getting
Commentsdoes not exposeModel.
How do you expose a type alias?
How do I set up Decoder for my example?