title: How to parses nested JSON, which also contains lists,in Haskell?
body: <p>I am trying to parse the fallowing JSON with aseon:</p>
  
  <p>JSON</p>
  
  <pre><code>{
    "response": [
      {
        "id": 5555,
        "brandId": 10,
        "productTypeId": 1,
        "identity": {
          "sku": "ABCDEF",
          "ean": "1111",
          "barcode": "2222"
        },
        "productGroupId": 17,
        "stock": {
          "stockTracked": true,
          "weight": {
            "magnitude": 0
          },
          "dimensions": {
            "length": 0,
            "height": 0,
            "width": 0,
            "volume": 0
          }
        },
        "financialDetails": {
          "taxable": false,
          "taxCode": {
            "id": 7,
            "code": "T1"
          }
        },
        "variations": [
          {
            "optionId": 1,
            "optionName": "option1",
            "optionValueId": 5,
            "optionValue": "5"
          },
          {
            "optionId": 2,
            "optionName": "option2",
            "optionValueId": 14,
            "optionValue": "OS"
          }
        ]
      },
      {
        "id": 9999,
        "brandId": 10,
        "productTypeId": 1,
        "identity": {
          "sku": "CDEFG",
          "ean": "111221",
          "barcode": "2443222"
        },
        "productGroupId": 17,
        "stock": {
          "stockTracked": true,
          "weight": {
            "magnitude": 0
          },
          "dimensions": {
            "length": 0,
            "height": 0,
            "width": 0,
            "volume": 0
          }
        },
        "financialDetails": {
          "taxable": false,
          "taxCode": {
            "id": 7,
            "code": "T1"
          }
        },
        "variations": [
          {
            "optionId": 1,
            "optionName": "option1",
            "optionValueId": 5,
            "optionValue": "5"
          },
          {
            "optionId": 2,
            "optionName": "option2",
            "optionValueId": 14,
            "optionValue": "14"
          }
        ]
      } 
    ]
  }
  </code></pre>
  
  <p>I have tried to set up the data structures and instances: Here is what I have so far:</p>
  
  <p>CODE</p>
  
  <pre><code>{-# LANGUAGE OverloadedStrings #-}
  
  import Data.Aeson 
  import Control.Applicative 
  import qualified Data.ByteString.Lazy.Char8 as BS
  
  
  
  data Response = Response                    { response              :: [Body]
                                              } deriving (Show)
  
  instance FromJSON Response where
      parseJSON (Object v) = Response &lt;$&gt;
                             v .: "response"                                             
  
  data Body = Body                            { idd                   :: Int
                                              , brandId               :: Int
                                              , productTypeId         :: Int
                                              , identity              :: Identity
                                              , productGroupId        :: Int
                                              , stock                 :: Stock
                                              , financialDetails      :: FinancialDetails
                                              , variations            :: [Variation]
                                              } deriving (Show)
  
  instance FromJSON Body where
      parseJSON (Object v) = Body &lt;$&gt;
                             (e &gt;&gt;= (.: "id")) &lt;*&gt;
                             (e &gt;&gt;= (.: "brandId")) &lt;*&gt;
                             (e &gt;&gt;= (.: "productTypeId")) &lt;*&gt;
                           -- DON'T KNOW HOW TO SET UP  IDENTITY  
                             (e &gt;&gt;= (.: "productGroupId"))
                           -- DON'T KNOW HOW TO SET UP STOCK  
                           -- DON'T KNOW HOW TO SET UP FINANCIAL DETAILS                          
                           -- DON'T KNOW HOW TO SET UP VARIATIONS  
                             where e = (v .: "response")                                              
  
  
  data Identity = Identity                    { sku                   :: String
                                              , ean                   :: String
                                              , barcode               :: String 
                                              } deriving (Show)
  
  data Stock = Stock                          { stockTracked          :: Bool
                                              , weight                :: Weight
                                              , dimensions            :: Dimensions
                                              } deriving (Show)
  
  data Weight = Weight                        { magnitude             :: Double
                                              } deriving (Show)
  
  data Dimensions = Dimensions                { length                :: Double
                                              , height                :: Double
                                              , width                 :: Double
                                              , volume                :: Double  
                                              } deriving (Show)       
  
  data FinancialDetails = FinancialDetails    { taxable               :: Bool
                                              , taxCode               :: TaxCode
                                              } deriving (Show)
  
  data TaxCode = TaxCode                      { id                    :: Int
                                              , code                  :: String
                                              } deriving (Show)    
  
  
  data Variation = Variation                  { optionId              :: Int
                                              , optionName            :: String
                                              , optionValueId         :: Int
                                              , optionValue           :: String
                                              }  deriving (Show)  
  </code></pre>
  
  <p>My problems are that I do not know how to bind the nested values nor can I figure out how to handle the list portions of the JSON. I have tried to go through the documentation and other stackoverflow questions; however I cannot find anything to help with this level of complexity.</p>
  
  <p>How would I go about getting objects for the nested values and for the listed values.</p>
  
  <p>Thanks</p>