Jackson JSON Processor
  1. Jackson JSON Processor
  2. JACKSON-834

Deserialize enums from int values using a static method annotated with @JsonCreator

    Details

    • Type: Improvement Improvement
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.9.7
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      1

      Description

      Similiar to JACKSON-193 it would be nice to be able to serialize/deserialize an enum by an integer value instead of a string.

      See attached example. The getId method with the @JsonValue annotation already works for serialization but the fromId method with the @JsonCreator annotation is ignored as long as the argument is not a string.

        Activity

        Hide
        Tatu Saloranta added a comment -

        Ok. So slight variation of JACKSON-749? (which was implemented for 2.0.0)

        Show
        Tatu Saloranta added a comment - Ok. So slight variation of JACKSON-749 ? (which was implemented for 2.0.0)
        Tatu Saloranta made changes -
        Field Original Value New Value
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Tatu Saloranta added a comment -

        Also, I thought this was actually working, too. Which version did you test it with?

        Show
        Tatu Saloranta added a comment - Also, I thought this was actually working, too. Which version did you test it with?
        Hide
        Tatu Saloranta added a comment -

        Ah. Never mind – it works for Strings, not for ints yet. Gotcha.

        Show
        Tatu Saloranta added a comment - Ah. Never mind – it works for Strings, not for ints yet. Gotcha.
        Hide
        Tatu Saloranta added a comment -

        Implemented.

        Show
        Tatu Saloranta added a comment - Implemented.
        Tatu Saloranta made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Fix Version/s 1.9.7 [ 18436 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Tatu Saloranta
            Reporter:
            Klaus Reimer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: