johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Struberg (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (JOHNZON-169) @JsonbTypeDeserializer(xxxJsonbDeserializer.class) is not working properly
Date Wed, 29 Aug 2018 12:34:00 GMT

    [ https://issues.apache.org/jira/browse/JOHNZON-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16596268#comment-16596268
] 

Mark Struberg commented on JOHNZON-169:
---------------------------------------

hiho! I've read through the spec and JavaDoc and I fear we have some gaps in both. I've now
created a spec ticket for it [https://github.com/eclipse-ee4j/jsonb-api/issues/89.]

 

So far Johnzon supports annotating the field (or setter):
{code:java}
public class SomeStudentsList { 
  @JsonbTypeDeserializer(StudentDeserializer.class)
  private List<Student> students = new ArrayList<>(); 
} 
{code}

Note that this supports the case where you have a json for each Student. If you just have
a String then you would need to use a `JsonbAdapter`.

> @JsonbTypeDeserializer(xxxJsonbDeserializer.class) is not working properly
> --------------------------------------------------------------------------
>
>                 Key: JOHNZON-169
>                 URL: https://issues.apache.org/jira/browse/JOHNZON-169
>             Project: Johnzon
>          Issue Type: Bug
>          Components: JSON-B
>    Affects Versions: 1.1.7
>         Environment: JDK8, Windows 10
>  
>            Reporter: Miroslav Nachev
>            Assignee: Mark Struberg
>            Priority: Blocker
>
> I have made my own JonsArray converter in JavaClass, which works properly when called
alone. For this purpose, I have used an annotation:
> @JsonbTypeDeserializer(Student.StudentDeserializer.class)
> public class Student \{...}
> public static class StudentDeserializer implements JsonbDeserializer<Student> \{...}
> The problem comes, when this object Student is part of an array (List), that is located
in another object:
> public class SomeStudentsList {
>  private List<Student> students = new ArrayList<>();
> }
> json=\{"students":[["Value-1","Value-2","Value-N"], ["Value-1","Value-2","Value-N"],
["Value-1","Value-2","Value-N"]]}
> The result exception is:
> Exception in thread "main" java.lang.UnsupportedOperationException: type class eu.nscenter.scilearn.manage.Student
not supported
> at org.apache.johnzon.mapper.MappingParserImpl.buildArray(MappingParserImpl.java:602)
> at org.apache.johnzon.mapper.MappingParserImpl.toObject(MappingParserImpl.java:518)
> at org.apache.johnzon.mapper.MappingParserImpl.toValue(MappingParserImpl.java:699)
> at org.apache.johnzon.mapper.MappingParserImpl.mapCollection(MappingParserImpl.java:644)
> at org.apache.johnzon.mapper.MappingParserImpl.buildArray(MappingParserImpl.java:594)
> at org.apache.johnzon.mapper.MappingParserImpl.toObject(MappingParserImpl.java:518)
> at org.apache.johnzon.mapper.MappingParserImpl.toValue(MappingParserImpl.java:699)
> at org.apache.johnzon.mapper.MappingParserImpl.buildObject(MappingParserImpl.java:338)
> at org.apache.johnzon.mapper.MappingParserImpl.readObject(MappingParserImpl.java:141)
> at org.apache.johnzon.mapper.MappingParserImpl.readObject(MappingParserImpl.java:133)
> at org.apache.johnzon.mapper.MappingParserImpl.readObject(MappingParserImpl.java:125)
> at org.apache.johnzon.mapper.Mapper.mapObject(Mapper.java:254)
> at org.apache.johnzon.mapper.Mapper.readObject(Mapper.java:189)
> at org.apache.johnzon.mapper.Mapper.readObject(Mapper.java:184)
> at org.apache.johnzon.jsonb.JohnzonJsonb.fromJson(JohnzonJsonb.java:58)
> at eu.nscenter.scilearn.manage.StudentsList.main(StudentsList.java:118)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message