[web-devel] when we switch to aeson, perhaps a QQ for JSON..

Michael Snoyman michael at snoyman.com
Thu Mar 17 07:49:57 CET 2011

I haven't used aeson much yet, but it *does* seem possible to generate
objects with ToJSON. In fact, the example given for an instance is:

data Coord { x :: Double, y :: Double }

instance ToJSON Coord where
   toJSON (Coord x y) = object ["x" .= x, "y" .= y]

I'm not opposed to creating some kind of QQ syntax if it will help
things out, but let's come up with some real-life use cases where the
built-in operators and functions are insufficient.


On Thu, Mar 17, 2011 at 8:44 AM, Max Cantor <mxcantor at gmail.com> wrote:
> ToJson doesn't seem to be able to generate JSON objects (key/value maps).  Also, one problem that I've had with other generic JSON libs is that they dont give you enough control over the JSON structure.  So, you need to write your client code around a particular JSON structure which can be unwieldy at times.
> max
> On Mar 17, 2011, at 1:37 PM, Greg Weber wrote:
>> Are you using the ToJson converter? I don't think QQ offers much advantage over utilities that can automatically convert haskell data structures to JSON. I believe aeson comes with this functionality and also some generics functionality if you define a Data instance.
>> http://hackage.haskell.org/packages/archive/json-enumerator/0.0.1/doc/html/Text-JSON-ToJson.html
>> On Wed, Mar 16, 2011 at 8:32 PM, Max Cantor <mxcantor at gmail.com> wrote:
>> I know that the kickass yesod team is looking to change the json library to aeson.
>> One nice feature would be quasi-quoting for the library like in the following library.
>> hackage.haskell.org/packages/archive/text-json-qq/0.2.0/doc/html/Text-JSON-QQ.html
>> _______________________________________________
>> web-devel mailing list
>> web-devel at haskell.org
>> http://www.haskell.org/mailman/listinfo/web-devel
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel

More information about the web-devel mailing list