I have a json array with multiple comments which can be nested.
exemple:
[
{
"author": "john",
"comment" : ".....",
"reply": "",
},
{
"author": "Paul",
"comment" : ".....",
"reply": [
{
"author": "john",
"comment" : "nested comment",
"reply": [
{
"author": "Paul",
"comment": "second nested comment"
}
]
},
{
"author": "john",
"comment" : "another nested comment",
"reply": ""
}
]
},
{
"author": "Dave",
"comment" : ".....",
"reply": ""
},
]
So it's a list of comment, which every comment can have a reply with an infinite number of reply.
With Json.Decode.list
I can decode the first level of comment, but how do I checked if there is some reply and then parse again ?
This is a simplify version of what I'm try to do. I'm actually trying to decode reddit comments. exemple
oneOf
, allowing you to either parse the empty strings (which you could manually convert to an empty list of replies) OR the nested replies. – Photoemission