Hi all,

I'm trying to decode an relatively large JSON to run my app in elm. here is 
the how my json looks like:

{
  "pageTitle" : "users",
  "primaryWidget" : "user"
  "primaryWidgetData" : {
    "permissions" : ["read", "write"]
    "data": [
      {
        "name": "name 1"
        "email" : "[email protected]"
        "id": "dsd33-wdsds"
      },
      {
        "name": "name 2"
        "email" : "[email protected]"
        "id": "0000-wdsds"
      }
    ]
  } 
}

alternatively my json can be like:

{
  "pageTitle" : "accounts",
  "primaryWidget" : "account-manager"
  "primaryWidgetData" : {
    "accounts": [
      {
        "accountId": "id 1"
        "accountName" : "acc name"
        "owner": {
          "name": "name 2"
          "email" : "[email protected]"
          "id": "0000-wdsds"
        }
      },
      {
        "accountId": "id 2"
        "accountName" : "acc name 2"
        "owner": {
          "name": "name 1"
          "email" : "[email protected]"
          "id": "3343-wdsds"
        }
      }
    ]
  }
}

when I'm decoding the JSON i would like to load  the relevant decoder based 
on the "primaryWidget" and I'm using pipeline decoder:

manifestDecoder : Decoder Manifest
manifestDecoder =
    Json.decode Manifest
        |> required "pageTitle" string
        |> required "primaryWidget" (string |> andThen primaryWidgetDecoder)
        |> required "primaryWidgetDat"  now I want to pass the relevant 
loader here but I have no Idea how. tried to use andThen but no luck 


Many thanks for reading and helping.

Cheers,


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