You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@johnzon.apache.org by "Markus Jung (Jira)" <ji...@apache.org> on 2024/02/10 13:28:00 UTC

[jira] [Assigned] (JOHNZON-401) Polymorphism attributes not serialized in nested objects

     [ https://issues.apache.org/jira/browse/JOHNZON-401?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Markus Jung reassigned JOHNZON-401:
-----------------------------------

    Assignee: Markus Jung

> Polymorphism attributes not serialized in nested objects
> --------------------------------------------------------
>
>                 Key: JOHNZON-401
>                 URL: https://issues.apache.org/jira/browse/JOHNZON-401
>             Project: Johnzon
>          Issue Type: Bug
>          Components: JSON-B
>    Affects Versions: 2.0.0
>            Reporter: Markus Jung
>            Assignee: Markus Jung
>            Priority: Major
>             Fix For: 2.1.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> See the following test:
> {code:java}
> package org.apache.johnzon.jsonb.polymorphism;
> import jakarta.json.bind.annotation.JsonbSubtype;
> import jakarta.json.bind.annotation.JsonbTypeInfo;
> import org.apache.johnzon.jsonb.test.JsonbRule;
> import org.junit.Rule;
> import org.junit.Test;
> import static org.junit.Assert.assertEquals;
> public class JsonbNestedPolymorphismTest {
>     @Rule public JsonbRule jsonb = new JsonbRule();
>     @Test
>     public void test()
>     {
>         Wrapper wrapper = new Wrapper();
>         wrapper.something = new ConcreteSomething();
>         assertEquals("{\"something\":{\"@type\":\"concrete\",\"value\":\"asdf\"}}", jsonb.toJson(wrapper));
>     }
>     @JsonbTypeInfo({
>             @JsonbSubtype(alias = "concrete", type = ConcreteSomething.class)
>     })
>     public static class AbstractSomething {
>     }
>     public static class ConcreteSomething extends AbstractSomething {
>         public String value = "asdf";
>     }
>     public static class Wrapper {
>         public AbstractSomething something;
>     }
> }
>  {code}
>  
> Test result:
> {code:java}
> org.junit.ComparisonFailure: 
> Expected :{"something":{"@type":"concrete","value":"asdf"}}
> Actual   :{"something":{"value":"asdf"}}
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)