I am new to Haskell and Yesod development. I try to parse JSON from Google Web Api using Aeson. My JSON is like
{
"html_attributions" : [],
"results" : [
{
"geometry" : {
"location" : {
"lat" : 47.2487941,
"lng" : 39.7119239
},
"viewport" : {
"northeast" : {
"lat" : 47.2488398,
"lng" : 39.71313905
},
"southwest" : {
"lat" : 47.24865699999999,
"lng" : 39.71151884999999
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/lodging-71.png",
"id" : "5aae9c47cad3016c64d3cc2c8d438ae656c8c0af",
"name" : "AMAKS Congress hotel",
"photos" : [
{
"height" : 2304,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/116238492021115373516/photos\"\u003eDmitry Semenov\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAP5F6Xu0nGvQ8wjAyY4ENNKEWzw8CohQU_2Z15oXWIQOvzwAOBQduK4OQfh-nRyw0iKCwLMS2o9fKanMcxpC4xop22SrxZI45OZWmvC-bTf80kJlgdnlU0q-AsncUxcP6sbfWMaTmAPCsqiAFLJhHwHD93VXCvyV2V4pC2CUpWKAEhBAr9aS0xoapQvNmvcUYfU7GhT3IKDXEdZ49LtEeMXMaBQKlNZ6DQ",
"width" : 4096
}
],
"place_id" : "ChIJNT2qOT7r40ARrxvwbj2Huxg",
"rating" : 4.1,
"reference" : "CmRRAAAAUR4QujRBtpkltqU51qCjuihX1JDEgX9ijFzkTeWGWkeQkw4spvaKqCPUrYit4jNs5AyT1hV-y0M72U2CtOTYgT_6chw5KAq0sB3l1k18BOoioDJqTL6HQ_kvqNn62ISIEhA-lNI9YXDt-cjErgJqHjGFGhQpYucBzRg9yilMU0MEn6b293lVUQ",
"scope" : "GOOGLE",
"types" : [
"bowling_alley",
"bakery",
"lodging",
"restaurant",
"food",
"store",
"point_of_interest",
"establishment"
],
"vicinity" : "проспект Михаила Нагибина, 19, Ростов-на-Дону"
},
/ more items here
"status" : "ok"
}
I created data for representing JSON:
data Restaurant = Restaurant {status :: Text} deriving (Show, Generic)
And it works, I can extract status. But when it comes to more complicated enclosed fields such as "results", I don't know how to describe and use it. So what should I write instead of ??? in
data Restaurant = Restaurant {results :: ???, status :: Text} deriving (Show, Generic)
And then how can I get access to items inside (name, rating, etc.)? Thank you!