Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #22710

Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc...

From Arved Sandstrom <asandstrom2@eastlink.ca>
Newsgroups comp.lang.java.programmer
Subject Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc...
References <dzdYs.98654$Sq4.71538@newsfe14.iad> <51340ae1$0$32109$14726298@news.sunsite.dk>
Message-ID <ma_Ys.2$PC7.1@newsfe03.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2013-03-04 05:53 -0400

Show all headers | View raw


On 03/03/2013 10:45 PM, Arne Vajhøj wrote:
> On 3/1/2013 9:34 PM, Arved Sandstrom wrote:
>> I just had an epiphany today at work. For years upon years I have used
>> Java libraries which have grown increasingly cumbersome and finicky and
>> unreliable to do XML or JSON in a REST context...99 percent of which is
>> actually super-simple.
>>
>> The epiphany came when neither Jettison (the default Jersey JSON
>> library) nor Jackson (which is undoubtedly more modern) could, out of
>> the box without arcane configuration tweaks, convert a single-item list
>> into a JSON array. They both just converted the item into a JSON object
>> and forgot about the array.
>>
>> Apparently this catches out a lot of people, judging by googling. The
>> Jackson solutions are many. The point being - leading to my epiphany -
>> why the hell is this even a problem?
>>
>> I have probably wasted tens of weeks on the arcana of Jersey, Jackson,
>> XStream to some extent, JAXB...I'm ditching most all of it. It is an
>> obstacle.
>>
>> XStream I actually like for producing and consuming XML. It works
>> nicely. I'll keep it in the toolbox. But for almost everything I do with
>> Java REST, there is no call for Jersey (nor Jackson et al. for JSON
>> (de-)serialization). It's a bunch of extra JARs for no added value.
>>
>> It occurred to me that for over 90 percent of my POJOs I can write
>> reliable toJSON() methods that *will not break* and are fully under my
>> control in a matter of minutes. For anything more I might give
>> simple-json a whirl - it actually has appealing simplicity.
>>
>> And Jersey has got to go. Why do we even drink that Kool-Aid? Once
>> you've got your JSON string a handful of lines of code with an HTTP
>> client will take care of your REST call. A lot more reliable.
>
> I think we need to split the stuff in 3 parts:
> A) server side framework to enable declarative JAX-RS to work in a
>     servlet container
> B) the JSON/POX serializer
> C) client side framework
>
> re A)
>
> I don't hear you argue against that. And I don't recall much
> criticism from other either.
 >
> re B)
>
> You don't like the common libraries. I know several people that
> don't like them either (I don't have so much personal experience).
>
> But is it really the concept that is wrong or is it just the
> implementations?
>
> My guess is still the implementations. I am not too keen on
> toJSON, toXML, toJSONAlternative, toXMLALternative etc.etc.
> on all DTO's.
>
> We may not always like SOAP and all the associated standards,
> but sometimes the "there is only one right way" philosophy
> do make life easier.
>
> re C)
>
> I think it is rather common to use plain HttpClient.
>
> Non-Java client to Java service is probably also a very
> common combination.
>
> Arne

For all of A, B, C, I have no problem with JSON as a data notation. I 
have no major problems with SOAP as a protocol, or with the principles 
of true RESTful web services [1].

For all of A, B, C, it is specifically implementations that I have a 
problem with. Whether language-specific APIs or libraries. JSON is 
simple. SOAP *messages* are usually quite simple (WSDL and schemas might 
not be, but you infrequently occupy your time with those). JSON as a 
payload over HTTP as part of a REST method is simple. SOAP XML via HTTP, 
JMS, SMTP is usually quite simple.

*When we look at what is going back and forth*, that's what is simple. 
What can be, and often is, elaborately over-engineered, clumsy, buggy, 
and not simple are the client and server APIs and libraries.

As to toJSON() or fromXml() type methods, I'm not overly keen on them 
either, for maintainability reasons. We very often have to explain to 
the client or server framework how to handle the DTO<->JSON/XML 
conversions, and annotations are superior to hardcoding for this. Except 
when they're not. :-)

AHS

[1] My uses of REST are almost always trivial. There is no 
hypertext-driven application state because the interactions are 
stateless in the REST sense. They may not be stateless in the system 
(DELETE, PUT, POST) but I never expect the client to follow-up on a REST 
call.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-01 22:34 -0400
  Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Joerg Meier <joergmmeier@arcor.de> - 2013-03-02 04:00 +0100
  Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-02 00:13 -0400
  Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2013-03-01 22:11 -0800
    Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-03-02 08:57 +0000
      Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-03 21:48 -0500
        Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-03-04 08:29 +0000
    Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-02 09:58 -0400
    Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Fredrik Jonson <fredrik@jonson.org> - 2013-03-02 14:46 +0000
      Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... markspace <markspace@nospam.nospam> - 2013-03-02 07:11 -0800
      Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-03 21:55 -0500
      Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Roedy Green <see_website@mindprod.com.invalid> - 2013-03-06 09:07 -0800
        Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-06 20:13 -0500
    Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-03 21:47 -0500
      Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... David Lamb <dalamb@cs.queensu.ca> - 2013-03-03 21:57 -0500
        Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-03 22:08 -0500
        Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-03 23:11 -0400
          Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-06 20:15 -0500
            Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-07 05:08 -0400
              Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-07 11:42 -0500
  Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-03 21:45 -0500
    Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-04 05:53 -0400
      Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-06 20:10 -0500
        Writing ones one Annotation processor (was: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc...) Joerg Meier <joergmmeier@arcor.de> - 2013-03-07 02:17 +0100
          Re: Writing ones one Annotation processor Arne Vajhøj <arne@vajhoej.dk> - 2013-03-06 20:36 -0500
        Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-07 06:39 -0400
          Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-07 11:41 -0500
            Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-07 20:28 -0400
              Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-07 21:24 -0500
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-08 05:49 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-03-08 12:20 +0000
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Leif Roar Moldskred <leifm@dimnakorr.com> - 2013-03-08 12:06 -0600
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-08 20:44 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 18:07 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Joerg Meier <joergmmeier@arcor.de> - 2013-03-11 23:27 +0100
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 18:33 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-11 21:12 -0300
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 20:24 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-11 21:38 -0300
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 20:58 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Robert Klemme <shortcutter@googlemail.com> - 2013-03-13 08:04 +0100
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 17:57 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Lew <lewbloch@gmail.com> - 2013-03-11 16:46 -0700
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 20:27 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 17:54 -0400

csiph-web