Hello, All

I do not understand how to work  Json.Decode.Pipeline for nested Json.

Json Structure
{
"count": "null",
"data": [
{
"configType": "2",
"date": "2012-02-07 11:51:29",
"desc": "Access Limiter",
"id": "26",
"term": "ACCESS_LIMITER"
},
{
"configType": "2",
"date": "2012-02-07 11:51:29",
"desc": "Sort top boxes",
"id": "2",
"term": "BOXES.SORT"
}
],
"messages": "",
"success": "true"
}

decodeRisResponse : Decode.Decoder RisConfigResponse
decodeRisResponse =
  decode RisConfigResponse
  |> required "count" Decode.string
  |> required "data" Decode.list
  |> required "message" Decode.string
  |> required "success" Decode.bool

decodeConfigs : Decode.Decoder (List Config)
decodeConfigs =
    Decode.list decodeConfig

decodeConfig : Decode.Decoder Config
decodeConfig =
    decode Config
    |> required "id" Decode.string
    |> required "term" Decode.string
    |> required "desc" Decode.string
    |> required "date" Decode.string
    |> required "configType" Decode.string

type alias RisConfigResponse =
  {
    count : String
    , data : (List Config)
    , message : String
    , success : Bool
  }



type alias ConfigId = String

type alias Config =
 {
    id: ConfigId
    , term : String
    , desc : String
    , date : String
    , configType : String
 }


But I have Error 

2:16:39 PM client.1 |  -- TYPE MISMATCH 
> -------------------------------------------- ./src/Commands.elm
> 2:16:39 PM client.1 |  The 2nd argument to function `required` is causing 
> a mismatch.
> 2:16:39 PM client.1 |  25|      required "data" Decode.list
> 2:16:39 PM client.1 |                           ^^^^^^^^^^^
> 2:16:39 PM client.1 |  Function `required` is expecting the 2nd argument 
> to be:
> 2:16:39 PM client.1 |      Decode.Decoder (List a)
> 2:16:39 PM client.1 |  But it is:
> 2:16:39 PM client.1 |      Decode.Decoder a -> Decode.Decoder (List a)
> 2:16:39 P


How do it parse "data" : (List Config) ? 

P.S. Sorry for my english ^)

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