我正在尝试执行以下代码:
new UserTrackingConsumer().
onMessage(new JSONObject(new UserTrackingMessage(UserTrackingEvent.ATC, "1230",
new Date(), "101", 10, "1.0.0", "android", "4.4", "test"))
.toString());
其中UserTrackingMessage构造函数是:
public UserTrackingMessage(UserTrackingEvent userTrackingEvent, String customerId,
Date dateTime, String productId, int quantity, String appVersion,
String device, String os, String property) {...}
和UserTrackingEvent是枚举:
public enum UserTrackingEvent {
PURCHASE("PURCHASE"), ATC("ATC");
private String eventName;
private UserTrackingEvent(String eventName) {
this.eventName = eventName;
}
@JsonValue
public String getEventName() {
return eventName;
}
}
我收到以下错误:
无法反序列化com.test.UserTrackingEvent的实例 START_OBJECT令牌
我尝试了所有可能的Json注释组合,但无法在预期的Json中包含该事件。