I'm struggling with parsing json data that contains different kinds of data.

My json structure looks like this:

[{event: A, data: {id: 1, name: 'foo'}}, event: B, data: {id: 1, address: 
'bar'}}]

I want to parse this structure to

type Event = EA A | EB B

type alias A = {id : Int, name: String}

type alias B = {id: Int, address: String}

decodeEvents : Json.Decode.Decoder List Event

So I want to write *decodeEvents*.

My question is, how can I do this? I want to write some if/case structure 
that checks the event name to parse the correct event.
I was thinking of using *oneOf* on the data, but the data can have the same 
structure for different events.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to