dev@jersey.java.net

Re: Invalid JSON data returned

From: Hisaaki Sato <hisato_at_beacon-it.co.jp>
Date: Wed, 2 Apr 2008 09:21:41 +0900 (JST)

Hi, Jakub

>I suggest you do not use attributes in such
>cases if possible.

OK,
but in the future, i want to use those attributes
with an element value.

Thanks,
Hisaaki Sato

--- "Jakub Podlesak" <Jakub.Podlesak_at_Sun.COM> ---

>Hi Hisaaki,
>
>Good catch! I have filed the issue as
>https://jersey.dev.java.net/issues/show_bug.cgi?id=54
>
>For a fix i need information from JAXB model
>which are not available for the JSON provider
>at the moment.
>
>I need to meet with Kohsuke at JavaOne
>and talk about better integration with JAXB.
>Hopefully will come out with something
>reasonable.
>
>In the meantime i plan to "fix" the issue
>the similar way as Jettison (via ommiting
>the <parent> element value, so that at least
>a valid JSON is provided.
>
>I suggest you do not use attributes in such
>cases if possible.
>
>Thanks,
>
>~Jakub
>
>
>On Tue, Apr 01, 2008 at 04:36:24PM +0900, $B:4F#!!5WL@(B wrote:
>> Hi,
>>
>> I have tried to get the JSON data by JSONJAXBContext
>> (using 'MAPPED' format),
>> but an invalid JSON data was returned.
>>
>> -> {"parent":{"@attr":"value1""attr1"}
>>
>> When i used 'MAPPED_JETTISON' or 'BADGERFISH' for JSON_NOTATION,
>> the result was as follows.
>>
>> -> {"parent":{"@attr":"attr1","$":"value1"}}
>>
>> I got the latest revision(ver.0.7 rev.898) from trunk and tried.
>>
>> --------
>> import javax.ws.rs.GET;
>> import javax.ws.rs.Path;
>> import javax.ws.rs.ProduceMime;
>> import javax.xml.bind.annotation.XmlAttribute;
>> import javax.xml.bind.annotation.XmlRootElement;
>> import javax.xml.bind.annotation.XmlValue;
>>
>> @Path("/jsonFormats")
>> public class SimpleJsonResource {
>>
>> @XmlRootElement(name="parent")
>> public static class ParentBean {
>> @XmlAttribute(name="attr")
>> public String attr = "attr1";
>> @XmlValue
>> public String value = "value1";
>> }
>>
>> @Path("json")
>> @GET
>> @ProduceMime({"application/json"})
>> public ParentBean getJson() {
>> return new ParentBean();
>> }
>>
>> @Path("xml")
>> @GET
>> @ProduceMime({"application/xml"})
>> public ParentBean getXml() {
>> return new ParentBean();
>> }
>> }
>>
>> --------
>>
>> Thanks,
>> Hisaaki Sato
>>


$B(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(B
$B!!>pJs9??e$+$iC&=P$9$k!"#W#e#b(B2.0$B>pJs%]!<%?%k!!!z(BinfoScoop$B!z(B
$B:#!"%(%s%?!<%W%i%$%:$GMxMQ2DG=$J%]!<%?%k$O$3$l$@$1$G$9!#$<$R!"$4Mw$/$@$5$$(B

$B!!!!!!!!"!;0I)El5~(BUFJ$B6d9T$N%7%9%F%`It$r;Y$($k%J%l%C%8%]!<%?%k;vNc"!(B
$B!!!!(Bhttp://www.beacon-it.co.jp/products/solution/ufjis/index.shtml
----------------------------------------------------------------------------
 $B!!-j(BBeacon IT $B%W%m%@%/%H3+H/It(B $BBh0l%A!<%`(B
 $B!!!!!!!!!!:4F#(B $B5WL@(B
 Tel 03(3340)2681 / Fax 03(3340)2614 / Ext: 1116/ 070-6435-1930(PHS)
 E-Mail: hisato@beacon-it.co.jp$B!!!~!!(BURL: http://www.beacon-it.co.jp
$B(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(,(0(B