I agree that ToJson as is now is biased towards arrays. I have some code like the below now. After we switch over we should make sure it is easy to create key-value objects. Perhaps we will need a second ToJson that is biased towards key-value objects instead of arrays.<div>

<div><div><br></div></div><div><div>documentToJson :: [Field] -&gt; J.Value</div><div>documentToJson = jsonMap . map toAssoc</div><div><br></div><div><div>toAssoc :: Field -&gt; (String, J.Value)</div><div>toAssoc (l := v) = (unpack l, toJson v)</div>

</div><div><br></div><div><br></div><div><br></div><br><div class="gmail_quote">On Wed, Mar 16, 2011 at 11:44 PM, Max Cantor <span dir="ltr">&lt;<a href="mailto:mxcantor@gmail.com">mxcantor@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">ToJson doesn&#39;t seem to be able to generate JSON objects (key/value maps).  Also, one problem that I&#39;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.<br>


<font color="#888888"><br>
max<br>
</font><div><div></div><div class="h5">On Mar 17, 2011, at 1:37 PM, Greg Weber wrote:<br>
<br>
&gt; Are you using the ToJson converter? I don&#39;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.<br>


&gt;<br>
&gt; <a href="http://hackage.haskell.org/packages/archive/json-enumerator/0.0.1/doc/html/Text-JSON-ToJson.html" target="_blank">http://hackage.haskell.org/packages/archive/json-enumerator/0.0.1/doc/html/Text-JSON-ToJson.html</a><br>


&gt;<br>
&gt; On Wed, Mar 16, 2011 at 8:32 PM, Max Cantor &lt;<a href="mailto:mxcantor@gmail.com">mxcantor@gmail.com</a>&gt; wrote:<br>
&gt; I know that the kickass yesod team is looking to change the json library to aeson.<br>
&gt;<br>
&gt; One nice feature would be quasi-quoting for the library like in the following library.<br>
&gt; <a href="http://hackage.haskell.org/packages/archive/text-json-qq/0.2.0/doc/html/Text-JSON-QQ.html" target="_blank">hackage.haskell.org/packages/archive/text-json-qq/0.2.0/doc/html/Text-JSON-QQ.html</a><br>
&gt; _______________________________________________<br>
&gt; web-devel mailing list<br>
&gt; <a href="mailto:web-devel@haskell.org">web-devel@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/web-devel" target="_blank">http://www.haskell.org/mailman/listinfo/web-devel</a><br>
&gt;<br>
<br>
</div></div></blockquote></div><br></div></div>