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" : "someem...@sd.cs"
        "id": "dsd33-wdsds"
      },
      {
        "name": "name 2"
        "email" : "anot...@sd.cs"
        "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" : "anot...@sd.cs"
          "id": "0000-wdsds"
        }
      },
      {
        "accountId": "id 2"
        "accountName" : "acc name 2"
        "owner": {
          "name": "name 1"
          "email" : "s...@sd.cs"
          "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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to