這是我從我的存根回傳的 JSON:
{
"brokerAccounts": [
{
"id": "4598",
"customTags": [
"main-buy"
]
}
]
}
這是一個物體的java類
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class InvestBrokerAccountsRs {
private List<InvestBrokerAccount> brokerAccounts;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public static class InvestBrokerAccount {
private String id;
private List<String> customTags;
}
}
在嘗試使用 Feign 獲得它之后,ResponseEntity<String>我得到了這個:
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.lang.String` out of START_OBJECT token
如我所見,我的 json 是有效的。我有@Data提供 getter 和 setter 的注釋。什么是問題?
uj5u.com熱心網友回復:
在我看來,這是負責任的 - ResponseEntity<String>。您正在嘗試將 json物件格式的 json 反序列化為字串,這是不可能的,因為字串格式不同。
我認為改為:
ResponseEntity<InvestBrokerAccountsRs>
應該解決你的問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/464779.html
上一篇:RUNsh腳本生成的DockerfileCOPY檔案
下一篇:com.sun.net.HttpServer SheduleExecutorService sheduleWithFixedDelay-命令可運行請幫助
