fstn
10/19/2017, 3:55 PM@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
data class FacebookRequest(
@JsonProperty("recipient") val recipient: RequestRecipient,
@JsonProperty("message") val message: RequestMessage? = null,
@JsonProperty("notification_type") val notificationType: NotificationType?,
@JsonProperty("sender_action") val senderAction: SenderAction? = null
)
I try to serialize it with:
(Json.encode(facebookRequest).toJsonAsBytes()
And I got :
io.vertx.core.json.EncodeException: Failed to encode as JSON: No serializer found for class java.lang.Object and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.github.parkee.messenger.model.request.FacebookRequest["message"]->com.github.parkee.messenger.model.request.RequestMessage["quickReplies"]->java.util.ArrayList[0]->com.github.parkee.messenger.model.request.quickreply.QuickReply["payload"])
at io.vertx.core.json.Json.encode(Json.java:65)
Any ideas?
I tried that:
Json.mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
I also try that:
val mapper = ObjectMapper().registerModule(KotlinModule())