johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: mixed object array
Date Thu, 08 Sep 2016 11:58:24 GMT
@Matthew: you can still use jettison as easily as dropping the jar and
setting a system property (or using jackson-jaxb). Don't want to rewrite a
thread about that but this migration reduced the number of json issues for
JAXRS services cause jettison mapping as a default just doesnt fit most of
the common needs "by design" + it was highly inconsistent with other
vendors and EE specification direction. Today we got few "migration"
questions on that area but really less "hey what the hell is this mapping?"
which was pretty common for tomee 1 so I still think it was right. Happy to
help you to make this migration smoother if you have some issue configuring
it.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-09-08 13:17 GMT+02:00 Matthew Broadhead <matthew.broadhead@nbmlaw.co.uk
>:

> i changed to send xml instead of jzon.  shame we can't use jaxb
> annotations anymore :(
>
> On 08/09/2016 12:03, Romain Manni-Bucau wrote:
>
>> Hello
>>
>> comments inline
>> <https://javaeefactory-rmannibucau.rhcloud.com>
>>
>>
>> 2016-09-08 11:56 GMT+02:00 Matthew Broadhead <
>> matthew.broadhead@nbmlaw.co.uk
>>
>>> :
>>> I am using TomEE 7.0.1 which is now defaulting to Johnzon where on 1.7.x
>>> the default was jettison.  i have a specific case where i am using jaxb
>>> annotations to specify a mixed object array where elements in the array
>>> can
>>> be for example ObjectType1 or ObjectType2.  using jettison it worked fine
>>> across jaxrs
>>>
>>> @XmlElements({ @XmlElement(name = "objectType1", type =
>>> ObjectType1.class),
>>>                          @XmlElement(name = "objectType2", type =
>>> ObjectType2.class) })
>>> @XmlElementWrapper
>>> public List getObjectBlocks() {
>>>          return objectBlocks;
>>> }
>>>
>>> I would be happy to use Johnzon instead of Jettison if it could provide
>>> an
>>> annotation that addresses this issue however i cannot find much
>>> documentation about johnzon.  or maybe johnzon has a way of supporting
>>> jaxb?
>>>
>>> No way to support jaxb cause jsonb (JSON mapping spec) doesnt match it
>> and
>> default johnzon mapper is very close to the spec which will prevent
>> several
>> migrations when targetting EE 8.
>>
>> On the serialization it should work out of the box, issue is on
>> deserialization side and here jaxb works cause it has wrappers and
>> namespace. This is not a common practise in JSON so there is no strict
>> equivalent. However one way to do that is to wrap at serialization time
>> the
>> instance in a wrapper containing the class. This is the solution on jsonb
>> side (see this test for instance
>> https://github.com/apache/johnzon/blob/745668a81818ec37aed31
>> dc6db868740191a9806/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/
>> SerializerTest.java#L65).
>> Johnzon has more or less the same kind of API through ObjectConverter, see
>> this other test
>> https://github.com/apache/johnzon/blob/745668a81818ec37aed31
>> dc6db868740191a9806/johnzon-mapper/src/test/java/org/
>> apache/johnzon/mapper/ObjectTypeTest.java#L163
>>
>>
>

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