[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [rest-practices] JSON style guidelines?

+1 on using Jackson. I'm not impressed with Jettison's stability and Jackson seems to have a lot more momentum behind it.

Jackson also I think supports JAXB annotations.

The Jettison approach + BadgerFish is only interesting, IMO, if you want to have an XML Schema that defines both your XML and JSON documents that represent the same information.

There's also JSON schema which I believe Jackson also supports.

For all, i think you should rely on the client to know what type to expect based on the URL they client *AND* the Content-Type returned. i.e.


*+json isn't "standardized", but IMO, that *+type style should be well understood.

James Bowes wrote:
Hi all:

For Candlepin, our primary media type is JSON. We've been using
RESTEasy with Jettison, which does:
JAXB annotated object -> XML -> JSON
As such, we're really representing the XML mappings of our objects in
JSON, rather than the objects themselves. Jettison is doing this with
the BadgerFish mapping convention, so we get JSON like:
  "consumer" : {
    "name" : "my consumer",
    "facts" : {
      "entry" : [
        { "key" : "memory", "value" : 12345 },
        { "key" : "memory.free", "value" : 60 }

My feeling is that if you're using JSON, you want it to be as compact as
possible. To that end, I've been working on using Jackson instead, which
cuts out the XML middleman, giving us JSON like:
  "name" : "my consumer",
  "facts" : {
    "memory" : 12345,
    "memory.free" : 60

The mapping of the "facts" hash is much nicer, but you do lose that
beginning "consumer" type hint. I was thinking we could add a
"type_hint" field inside the returned object instead, or just rely on
the client to know what type to expect based on the url they hit.

What is the opinion of the list? Is anyone aware of any gotchas with the
various JSON styles for autogenerating class representations?




rest-practices mailing list
rest-practices redhat com

Bill Burke
JBoss, a division of Red Hat

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]