Details

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

      Description

      I'm trying to combine JsonCreator and JacksonInject like so:

      public class Blah
      {
      private final String howdy;
      private final Object value;

      @JsonCreator
      public Blah(
      @JacksonInject("howdy") String howdy,
      Object value
      )

      { this.howdy = null; this.value = value; }

      @Override
      public String toString()
      {
      return "Blah

      {" + "howdy='" + howdy + '\'' + ", value=" + value + '}

      ';
      }

      public static void main(String[] args) throws IOException

      { ObjectMapper mapper = new ObjectMapper(); mapper.setInjectableValues( new InjectableValues.Std(ImmutableMap.<String, Object>of("howdy", "ho")) ); System.out.println(mapper.readValue("[\"what?\", \"huh\"]", Blah.class)); }

      }

      I want this to write out

      Blah

      {howdy='ho', value=[what?, huh]}

      But instead it complains about not having a JsonProperty annotation on
      a multi-parameter constructor annotated with JsonCreator. Is this
      just not possible (I essentially want to use JacksonInject along with
      a delegate-style JsonCreator method).

        Activity

        Hide
        Tatu Saloranta added a comment -

        Hmmh. Turns out that implementation is bit trickier than I thought; so I added unit test (under 'failing' group), and did minor refactoring to separate this case from other failures.
        For now there will be different exception (basically pointing out that DelegateCreator with injectables is not yet supported), until this gets implemented.

        Show
        Tatu Saloranta added a comment - Hmmh. Turns out that implementation is bit trickier than I thought; so I added unit test (under 'failing' group), and did minor refactoring to separate this case from other failures. For now there will be different exception (basically pointing out that DelegateCreator with injectables is not yet supported), until this gets implemented.
        Hide
        Tatu Saloranta added a comment -

        Fixed for 2.0.

        Show
        Tatu Saloranta added a comment - Fixed for 2.0.
        Hide
        Tim Peierls added a comment -

        Workaround for 1.9 is to add @JsonProperty("dummyN") to all injected constructor arguments that otherwise aren't properties, for different values of N, of course.

        Show
        Tim Peierls added a comment - Workaround for 1.9 is to add @JsonProperty("dummyN") to all injected constructor arguments that otherwise aren't properties, for different values of N, of course.

          People

          • Assignee:
            Tatu Saloranta
            Reporter:
            Eric Tschetter
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: