Text.JSON Questions

R Hayes rfhayes at reillyhayes.com
Tue Jul 29 00:48:40 EDT 2008

I'm using Haskell to build a web services client.  The API uses JSON,  
so I've been playing around with Text.JSON.  Text.JSON works, but it  
seems kind of clumsy to me.  I suspect that it's my failure to  
understand the proper usage pattern, rather than an issue with the  

For much of what I'm doing, I don't know *exactly* what I'm going to  
get back.  I know that there will be specific JSON fields I'm  
interested in, but there may be ones I'm not expecting.  Writing a  
readJSON for a pre-designed data structure is not the right answer.   
I'm not marshalling and un-marshalling structures that originate in  
Haskell.  The structures I am un-marshalling are subject to extension.

it seems like the default invocation of decode is something like:
	(decode aString) :: Result JSValue

Is that correct?

I'm unclear on the design goals of parameterizing JSObject.  Why isn't  
JSObject just a list of (String,JSValue) tuples?  What do we get from  
parameterizing it?

What's the intent of having JSObject as a data constructor for JSValue  
and as a distinct type constructor (whose hidden data constructor is  
JSONObject)?  What do we get from this?  Why hide JSONObject?  The way  
things are constructed, we always end up with two layers of data  
constructors for JSON objects JSObject (JSONObject ...).  What do we  
get from this additional complexity.

-r hayes

More information about the Libraries mailing list