On Tue, Mar 21, 2017 at 12:16 AM, Zsolt Balanyi <zsolt.bala...@gmail.com> wrote:
> Hi!
>
> That was one of my first attempts :)
>
> <Page>
>   <uiElement>
>     <StackLayout>
>       <uiElements>
>         <Label text="some text"/>
>       </uiElements>
>       <uiElements>
>         <Image url="mypageUrl"/>
>       </uiElements>
>     </StackLayout>
>   </uiElement>
> </Page>
>
> The question is how could I ommit the uiElement nodes?

<uiElement> itself matches property `uiElement` so that can not be removed.
Or, if expectation was that property name would be replaced by type id
that is not something Jackson supports or will be able to support --
it may make sense from XML viewpoint, but would not work with JSON or
any other supported dataformat. XML is bit of an outlier as its
structural model is the most difficult one to support, of formats
supported.

-+ Tatu +-

>
> BR, Zsolt
>
> 2017. március 20., hétfő 20:16:38 UTC+1 időpontban Tatu Saloranta a
> következőt írta:
>>
>> Have you tried choice of `JsonTypeInfo.As.WRAPPER_OBJECT`?
>> That does add type id as property-name "wrapper" in JSON, and should
>> work quite similarly with XML.
>> The main problem with XML is often, however, that the root value
>> requires additional extra XML element.
>>
>> -+ Tatu +-
>>
>> On Mon, Mar 20, 2017 at 11:42 AM, Zsolt Balanyi <zsolt....@gmail.com>
>> wrote:
>> > Hi!
>> >
>> > public class Page {
>> >    public UIElement uiElement;
>> > }
>> >
>> > @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include =
>> > JsonTypeInfo.As.PROPERTY, property = "type")
>> > public abstract class UIElement {
>> > }
>> >
>> > public class StackLayout extends UIElement {
>> >     public List<UIElement> uiElements = new ArrayList<>();
>> > }
>> >
>> > public class Label extends UIElement {
>> >     @JacksonXmlProperty(isAttribute=true)
>> >     public String text;
>> > }
>> >
>> > So basically I have  a Page, that contains a  StackLayout that contains
>> > a
>> > Label and an Image.
>> > It would solve the problem, if the JsonTypeInfo could put the type name
>> > to
>> > the element name...
>> >
>> > BR, Zsolt
>> >
>> > 2017. március 20., hétfő 19:22:10 UTC+1 időpontban Tatu Saloranta a
>> > következőt írta:
>> >>
>> >> What is the POJO you are serializing?
>> >>
>> >> -+ Tatu +-
>> >>
>> >>
>> >> On Mon, Mar 20, 2017 at 5:11 AM, Zsolt Balanyi <zsolt....@gmail.com>
>> >> wrote:
>> >> > Hi!
>> >> >
>> >> > I have a structure that outputs this:
>> >> >
>> >> > <Page>
>> >> >   <uiElement type="StackLayout">
>> >> >     <uiElements type="Label" text="some text"/>
>> >> >     <uiElements type="Image" url="mypageUrl"/>
>> >> >   </uiElement>
>> >> > </Page>
>> >> >
>> >> > I use @JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=As.PROPERTY,
>> >> > property="type") on the common base class.
>> >> > How could I get the following output:
>> >> >
>> >> > <Page>
>> >> >   <StackLayout>
>> >> >     <Label text="some text"/>
>> >> >     <Image url="mypageUrl"/>
>> >> >   </StackLayout>
>> >> > </Page>
>> >> >
>> >> > It does not matter, if it can not be deserialized by Jackson, it is
>> >> > read
>> >> > by
>> >> > another system, that requires this structure.
>> >> >
>> >> > BR, Zsolt
>> >> >
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups
>> >> > "jackson-user" group.
>> >> > To unsubscribe from this group and stop receiving emails from it,
>> >> > send
>> >> > an
>> >> > email to jackson-user...@googlegroups.com.
>> >> > To post to this group, send email to jackso...@googlegroups.com.
>> >> > For more options, visit https://groups.google.com/d/optout.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "jackson-user" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to jackson-user...@googlegroups.com.
>> > To post to this group, send email to jackso...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "jackson-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jackson-user+unsubscr...@googlegroups.com.
> To post to this group, send email to jackson-user@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jackson-user+unsubscr...@googlegroups.com.
To post to this group, send email to jackson-user@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to