Encoding and decoding UTF-8 JSON content.
This module is a thin wrapper around the most excellent
aeson
library, which has rich and powerful facilities for encoding Haskell
types into JSON.
Quite often, however, you find yourself having to create a Haskell
type
just to read some JSON coming from an external web service
or API. This can be challenging when the source of the JSON is complex
or varying its schema over time. For ease of exploration this module
simply defines an easy to use intermediate type representing JSON as a
format.
Often you'll be working with literals directly in your code. While you
can write:
j = JsonObject (intoMap [(JsonKey "answer", JsonNumber 42)])
and it would be correct, enabling:
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedLists #-}
allows you to write:
j = JsonObject [("answer", 42)]
which you is somewhat less cumbersome in declaration-heavy code.
You're certainly welcome to use the constructors if you find it makes
for more readable code or if you need the type annotations.