title: Configure jackson to use single-arg constructor
body: <p>I have an immutable object <code>SimpleGrantedAuthority</code> from spring which does not have a no-arg constructor. Instead it is an immutable object with only 1 single-arg constructor like this:</p>
  
  <pre><code>public SimpleGrantedAuthority(String role) {
      Assert.hasText(role, "A granted authority textual representation is required");
      this.role = role;
  }
  </code></pre>
  
  <p>I'm trying to deserialize a string to this object and I don't have access to the source code of this file. Here's the exception I get:</p>
  
  <pre><code>Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.springframework.security.core.authority.SimpleGrantedAuthority: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
  at [Source: java.util.zip.GZIPInputStream@e1fb329; line: 7, column: 7] (through reference chain: com.nemesis.platform.facade.email.data.EnrichedEmailMessageContextData["customer"]-&gt;com.nemesis.platform.facade.user.data.EnrichedUserDetails["authorities"]-&gt;java.util.ArrayList[0])
  at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270)
  at com.fasterxml.jackson.databind.DeserializationContext.instantiationException(DeserializationContext.java:1456)
  </code></pre>
  
  <p>Like I said I don't have the source code and I cannot add the <code>@JsonCreator</code> annotation, so I'm wondering how to configure jackson to understand the correct constructor to use. Something in the likes of:</p>
  
  <pre><code>    Module module = new SimpleModule("MyModule") {
  
          @Override
          public void setupModule(Module.SetupContext context) {
              context.addAbstractTypeResolver(new SimpleAbstractTypeResolver().addMapping(GrantedAuthority.class, SimpleGrantedAuthority.class));
          }
      };
  </code></pre>
  
  <p>Thank you</p>
  
  <p><strong>EDIT</strong> </p>
  
  <p>I tried the suggestion of Shashank so I created this class:</p>
  
  <pre><code>abstract class SimpleGrantedAuthorityMixIn {
      @JsonCreator
      SimpleGrantedAuthorityMixIn(@JsonProperty("authority") String authority) {
      }
  }
  </code></pre>
  
  <p>and then I registered it like this:</p>
  
  <pre><code>    Module module = new SimpleModule("SamplestoreModule") {
  
          @Override
          public void setupModule(Module.SetupContext context) {
              context.addAbstractTypeResolver(new SimpleAbstractTypeResolver().addMapping(GrantedAuthority.class, SimpleGrantedAuthority.class));
              context.setMixInAnnotations(SimpleGrantedAuthority.class, SimpleGrantedAuthorityMixIn.class);
          }
      };
  
      objectMapper.registerModule(module);
      objectMapper.addMixIn(SimpleGrantedAuthority.class, SimpleGrantedAuthorityMixIn.class);
  </code></pre>
  
  <p>but I still see the same exception.</p>