Better json through jackson

James Bowes jbowes at redhat.com
Mon May 17 12:44:47 UTC 2010


All:

I've pushed out a new branch for some fiddling I did on Friday night to
move from jettison for json reading/writing to jackson. IMO jackson
creates much nicer json. Here's what a consumer looks like:

== OLD ==

{"consumer" : {
    "name" : "my consumer",
    "type" : {"label" : "system" }
    }
}

== NEW ==

{"name" : "my consumer",
 "type" : "system"}

Through nicer json, we get nicer client code (fewer redundant
variable/key names).

Another cool think about jackson is it can generate json schema, which
I've hooked up in a few cases to the ApiCrawler.

Before bringing this into master, I'd like to:
 * make sure the java client speaks new json
 * come up with a convention for variable names in json. I'd like to do:
   endDate => end_date, as I think the underscore looks more jsonic.
   enforce this convention.
 * Create our own json reader/writer so we can configure jacksons
   settings for:
     * Use "YYYY-MM-DDTHH:MM:SS-04:00" for datetime, rather than seconds
       since the epoch
     * allow a configurable toggle for json pretty printing (great for
       debugging)
     * Have the hooks in place for input validation (do after merge)
 * Check for any concessions we made with jettison re base64 encoding or
   int to string conversion, and elimnate them.
 * consider dropping xml support, or consider using jaxb annotations for
   jackson.

I've also got patches for the python code locally, for when we switch.

Comments?


-James
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/candlepin/attachments/20100517/51c05c13/attachment.sig>


More information about the candlepin mailing list