2
class AgentResponse[T] @JsonCreator()(@JsonProperty("result") val result: T, @JsonProperty("status") val status: ResponseStatus)
class ResponseStatus @JsonCreator()(@JsonProperty("succeeded") val succeeded: Boolean, @JsonProperty("message") val message: String, @JsonProperty("timeStamp") val timeStamp: Long)
new ObjectMapper().registerModule(DefaultScalaModule).writer().writeValue(out, new AgentResponse(result, new ResponseStatus(true, "OK", now)))
它抛出错误:如何使用Jackson对多参数构造函数序列化scala对象?
JsonMappingException: No serializer found for class com.fg.mail.smtp.rest.Handler$AgentResponse and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.SerializationFeature.FAIL_ON_EMPTY_BEANS))
斯卡拉对象如何看起来应该像为它达到预期效果?
感谢Peter,您当场了。 – lisak
@Sloin请让我知道它是否正常工作。我没有时间去测试它。 –
是的,它现在按预期工作,谢谢 – lisak