안녕하세요, 잭슨을 직렬화하고 보호 된 생성자와 클래스 (SimpleExpression) deserialize 위해 노력하고있어. gson을 사용할 때 아무 문제가 없지만 jackson이 보호 된 생성자를 처리 할 수없는 것 같습니다. mixin-annotations를 사용해 보았지만 일하지 않았습니다. 직렬화는 문제없이 작동합니다. Jackson throws :잭슨과 보호 된 생성자를 deserialize
com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type
도움이 필요하십니까? 내 코드 :
private static SimpleExpression create(String json) throws JsonParseException, JsonMappingException, IOException
{
ObjectMapper mapper = new ObjectMapper().setVisibility(PropertyAccessor.ALL, Visibility.ANY);
SimpleExpression sp = null;
sp = mapper.readValue(json, SimpleExpression.class);
return sp;
}
SimpleExpression 클래스는, 나는 getter와 setter를 omiting하고 있습니다.
public class SimpleExpression implements Criterion
{
private static final long serialVersionUID = 1L;
private final String propertyName;
private final Object value;
private boolean ignoreCase;
private final String op;
private final String type;
protected SimpleExpression(String propertyName, Object value, String op)
{
this.propertyName = propertyName;
this.value = value;
this.op = op;
this.type = value.getClass().getName();
}
protected SimpleExpression(String propertyName, Object value, String op, boolean ignoreCase)
{
this.propertyName = propertyName;
this.value = value;
this.ignoreCase = ignoreCase;
this.op = op;
this.type = value.getClass().getName();
}
}
당신은 SimpleExpression''의 클래스 데프을 포함해야한다가 괜찮 았는데. – StaxMan
나는 그것을 잊어 버렸다. 그냥했다. –