users@jersey.java.net

[Jersey] Re: [Jersey 2.x] [MOXy] Problems with JSON_INCLUDE_ROOT

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Fri, 9 Aug 2013 10:51:19 +0200

Hi Norbert,

There is a RFE filed for a similar use case already (see [1]).
You might want to comment on the above and
request your use case is taken into consideration there.
Otherwise you can directly experiment with the MOXy
@XmlNamedObjectGraph feature to achieve your goal.

HTH,

~Jakub

[1]https://java.net/jira/browse/JERSEY-2013

On Aug 9, 2013, at 1:36 AM, Norbert Kiesel <nkiesel_at_MetricStream.com> wrote:

> Hi,
>
> given e.g. a simple address POJO, I want to get the following replies when asking for the whole address or just an element of it:
>
> GET /address/1 => { "id" : 1, "name": "John Doe" }
> GET /address/1/name => { "name": "John Doe" }
>
> Setting JSON_INCLUDE_ROOT to true results in
>
> GET /address/1 => {"address" : { "id" : 1, "name": "John Doe" }}
> GET /address/1/name => { "name": "John Doe" }
>
> Setting JSON_INCLUDE_ROOT to false results in
>
> GET /address/1 => { "id" : 1, "name": "John Doe" }
> GET /address/1/name => { "value": "John Doe" }
>
> I tried to use a different config based on the Java type but could not make it work.
>
>
> </nk>
>
> ---
>
>
> Norbert Kiesel
> Systems Architect | Engineering
> MetricStream
> 2600 E. Bayshore Road | Palo Alto, CA - 94303
> +1-650-620-2954 | nkiesel_at_metricstream.com | www.metricstream.com
> Confidentiality Notice:This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited