Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Haskell for Web Developers. Parent comment
object [ "foo" .= object [ "bar" .= [ "Yum", "Waffles!"] ] ]
Which will give you {"foo": {"bar": ["Yum", "Waffles!"]}}.
You can do traversals when decoding too:
tasty :: JSON -> Parser [String] tasty json = json .: "foo" >>= (.: "bar")
You can also do similar things with lens-aeson:
tasty json = json & key "foo" . key "bar" . _Array
Though I'm less familiar with that, and you won't be inside the Parser monad.
There are no comments on this comment yet.
object [ "foo" .= object [ "bar" .= [ "Yum", "Waffles!"] ] ]
Which will give you {"foo": {"bar": ["Yum", "Waffles!"]}}.
You can do traversals when decoding too:
tasty :: JSON -> Parser [String] tasty json = json .: "foo" >>= (.: "bar")
You can also do similar things with lens-aeson:
tasty json = json & key "foo" . key "bar" . _Array
Though I'm less familiar with that, and you won't be inside the Parser monad.