We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR #590 fixes this issue
I get the next exception : Unable to deserialize property 'elements' because of: Unexpected state: KEY_NAME
I don't know how to describe exactly the issue, but i provide some tests cases with failure and successes.
YassonBugTest.txt
package yasson.testcase; import jakarta.json.Json; import jakarta.json.JsonStructure; import jakarta.json.bind.JsonbBuilder; import jakarta.json.bind.annotation.JsonbSubtype; import jakarta.json.bind.annotation.JsonbTypeInfo; import org.eclipse.yasson.YassonJsonb; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.StringReader; import java.util.List; public class YassonBugTest { YassonJsonb jsonb; @BeforeEach void beforeEach() { jsonb = (YassonJsonb) JsonbBuilder.create(); } @Test void test00_work_with_MyCanvas_type_and_list() { // We deserialize a List // But we give MyCanvas as type System.out.println(jsonb.toJson(jsonb.fromJson(""" { "@type": "canvas", "elements": [ { "@type": "note" } ] } """, MyCanvas.class))); } @Test void test01_work_with_MyObject_without_list() { // We don't deserialize a List System.out.println(jsonb.toJson(jsonb.fromJson(""" { "@type": "canvas", "element": { "@type": "note" } } """, MyObject.class))); } @Test void test02_doesnt_work_with_MyObject_type_with_list() { // We deserialize a List System.out.println(jsonb.toJson(jsonb.fromJson(""" { "@type": "canvas", "elements": [ { "@type": "note" } ] } """, MyObject.class))); } @Test void test03_doesnt_work_with_structure_and_MyCanvas_type_and_list() { // We deserialize a List JsonStructure structure = Json.createReader(new StringReader(""" { "@type": "canvas", "elements": [ { "@type": "note" } ] } """)).read(); System.out.println(jsonb.toJson(jsonb.fromJsonStructure(structure, MyCanvas.class))); } @Test void test04_work_with_structure_and_MyCanvas_type_without_list() { // We don't deserialize a List JsonStructure structure = Json.createReader(new StringReader(""" { "@type": "canvas", "element": { "@type": "note" } } """)).read(); System.out.println(jsonb.toJson(jsonb.fromJsonStructure(structure, MyCanvas.class))); } @JsonbTypeInfo({ @JsonbSubtype(alias = "canvas", type = MyCanvas.class)}) public static class MyObject { } public static class MyCanvas extends MyObject { public List<MyElement> elements; public MyElement element; } @JsonbTypeInfo({ @JsonbSubtype(alias = "element", type = MyElement.class), @JsonbSubtype(alias = "note", type = MyNote.class)}) public static class MyElement { public Double x; public Double y; } public static class MyNote extends MyElement { } }
The text was updated successfully, but these errors were encountered:
remimarechal
No branches or pull requests
PR #590 fixes this issue
I get the next exception :
Unable to deserialize property 'elements' because of: Unexpected state: KEY_NAME
I don't know how to describe exactly the issue, but i provide some tests cases with failure and successes.
YassonBugTest.txt
The text was updated successfully, but these errors were encountered: