I have situation where I have to a jso object similar to this

{ "level": 1, "displayValue": "some text", "dataValue": "a string with the 
value" }

{ "level": 1, "displayValue": "some text", "dataValue": { "name": "xxx", 
"scope": "xxxx" } }

Both cases for dataValue are valid, it can either have a string or an 
object.

I have created types as such:

type DataValue
  = Val String
  | Key KeyType

type alias KeyType =
 { name: String, source: String }

type alias MyObj = 
 { level: Int, displayValue: String, dataValue: DataValue}

How can I decode dataValue for MyObj?

Thanks 

-- 
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