com.fasterxml.jackson.databind.JsonMappingException: Missing required creator property 'Subject' (index 3)
disable(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES); I've searched everywhere and stepped through the code and can't figure out why it's not working.
Any help would be great!
Message:
public class Message
{ private final String Type; private final String MessageId; private final String Subject;
@java.beans.ConstructorProperties({ "Type", "MessageId", "Subject" }) public Message(final String Type, final String MessageId, final String Subject) { this.Type = Type; this.MessageId = MessageId; this.Subject = Subject; }
public String getType() { return this.Type; }
public String getMessageId() { return this.MessageId; }
public String getSubject() { return this.Subject; }}
Mapper:
public final class MessageMapper extends ObjectMapper
{
public MessageMapper()
{
disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
disable(SerializationFeature.INDENT_OUTPUT);
disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
// disable(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES);
enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY);
setSerializationInclusion(JsonInclude.Include.ALWAYS);
registerModule(new JodaModule());
registerModule(new GuavaModule());
setAnnotationIntrospector(new ConstructorPropertiesAnnotationIntrospector());
}
}
Code throwing the error:
MessageMapper mapper = new MessageMapper();
final Message body = mapper.readValue(json, Message.class); //Where json is the Json string to be parsed.
Json Objects:
object1: {"Type":"Notify", "MessageId":"1234567890", "Subject":"Topic1"}
object2: {"Type":"Notify", "MessageId":"0987654321"}--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
To post to this group, send email to jackso...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.