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] [Created] (JOHNZON-185) deserialising an illegal enum value should blow up with an Exception
Date Wed, 29 Aug 2018 16:26:00 GMT
Mark Struberg created JOHNZON-185:
-------------------------------------

             Summary: deserialising an illegal enum value should blow up with an Exception
                 Key: JOHNZON-185
                 URL: https://issues.apache.org/jira/browse/JOHNZON-185
             Project: Johnzon
          Issue Type: Improvement
          Components: JSON-B
    Affects Versions: 1.1.8
            Reporter: Mark Struberg
            Assignee: Mark Struberg
             Fix For: 1.1.9


Right now if we deserialise a enum value which is not know we simply set the field to null

{code}
public enum Status {ON, OFF;}

public class Engine {
   private Status status;
}

json: {"status": "BLABLA"}
{code}

What I found in the spec is the following paragraph:
{noformat}
Deserialization of a JSON value into an enum instance MUST be done by calling the enum’s
valueOf(String) method.
{noformat}
And valueOf should throw an IllegalArgumentException.



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

Mime
View raw message