I have json like this:
{
"username": "john",
"email": "john@gmail.com",
"items": [
{
"id": "id 1"
},
{
"id": "id 2"
}
]
}
I need to decode it in List Item. An item is a record like this.
type alias Item =
{ id : String
, user : User
}
type alias User =
{ username : String
, email : String
}
I want to extract username and email address from top level json. Then create an entry User, and then put that user in each entry Itemin List Item.
I understand that this can be done using Decode.andThen, but cannot make it work.
For decoding, I use json-decode-pipeline .
thank
source
share