dev@jersey.java.net

Re: Invalid JSON data returned

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Wed, 02 Apr 2008 09:11:13 +0200

Hi Hisaaki,

On Wed, Apr 02, 2008 at 09:21:41AM +0900, Hisaaki Sato wrote:
> 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.

Understood.

I am going to fix the issue so that
JSON expression for

<e a="aval">val1</e>

would be:

{"e":{"@a":"aval", "$":"val1"}}

Will it then work for you?
If not, do you have any suggestion how the JSON
expression should look like?

Thanks,

~Jakub

>
> 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, 佐藤 久明 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
> >>
>
>
> ━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛
>  情報洪水から脱出する、Web2.0情報ポータル ★infoScoop★
> 今、エンタープライズで利用可能なポータルはこれだけです。ぜひ、ご覧ください
>
>     ◆三菱東京UFJ銀行のシステム部を支えるナレッジポータル事例◆
>   http://www.beacon-it.co.jp/products/solution/ufjis/index.shtml
> ----------------------------------------------------------------------------
>  ?jBeacon IT プロダクト開発部 第一チーム
>      佐藤 久明
> Tel 03(3340)2681 / Fax 03(3340)2614 / Ext: 1116/ 070-6435-1930(PHS)
> E-Mail: hisato@beacon-it.co.jp ◇ URL: http://www.beacon-it.co.jp
> ━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛━┛
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>