3 ms·
When it comes to encoding JSON, you don't have to represent everything. For example, you can always do: object [ "foo" .= object [ "bar" .= [ "Yum", "Waffles!"
by ocharles 13y ago
When it comes to encoding JSON, you don't have to represent everything. For example, you can always do:
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.