abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Diephouse" <...@envoisolutions.com>
Subject Jettison for JSON support?
Date Tue, 05 Dec 2006 05:02:28 GMT
Been playing around with Abdera a little and was thinking about putting
together a patch to use Jettison for its JSON support [1]. Jettison is a
StAX implementation I wrote for use in CXF that can read/write JSON. It can
do so in different ways as well - like BadgerFish mode and mapped mode. The
current code seems to require a distinct knowledge of all the different Atom
elements and how to serialize it to JSON. With Jettison the idea is you can
just reuse the existing stax code that you have.

I think the one weekness of Jettison currently is that it doesn't have a "no
namespace mode" where it just automatically ignores the namespace. Jettison
has a mapped mode where you can map namespaces to prefixes. So I can map a
namespace http://www.w3.org/2005/Atom to "atom" and it would output json
like "atom.feed". You can also just specify an empty prefix:

Map xmlNsToJSON = new HashMap();
xmlNsToJSON.put("http://www.w3.org/2005/Atom", "");

XMLStreamWriter writer = new

And get this out:

{ "feed" : { "title" : "...", "link" : { "@href" : "..." } ... } }

Its not that much work to specify the mapping manually, but a no namespace
mode might be handy if a user has custom extension elements and they just
want to default to having no json prefix

But I digress... To recap: to me the advantages would be:
- No JSON module required in the build
- Different JSON mappings are supported by Jettison
- No need to maintain manual JSON mapping code
- Reading is supported too (currently I only see a JSONWriter...)

Thoughts? I can put together a patch real easy for this. Just wondering if
the patch should rip out the existing JSON support and replace it with
Jettison, if I should add it as an incremental enhancement, or if I should
bugger off :-)

- Dan

1. http://jettison.codehaus.org
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message