Uploaded image for project: 'Johnzon'
  1. Johnzon
  2. JOHNZON-185

deserialising an illegal enum value should blow up with an Exception

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.8
    • 1.1.9
    • JSON-B
    • None

    Description

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

      public enum Status {ON, OFF;}
      
      public class Engine {
         private Status status;
      }
      
      json: {"status": "BLABLA"}
      

      What I found in the spec is the following paragraph:

      Deserialization of a JSON value into an enum instance MUST be done by calling the enum’s valueOf(String) method.
      

      And valueOf should throw an IllegalArgumentException.

      Attachments

        Activity

          People

            struberg Mark Struberg
            struberg Mark Struberg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: