java无法反序列化具有int的字符串类型的值
输入JSON
{
"MAJOR_DISEASES": "",
"DEFICIENCIES": "\n1.INDOORCASEPAPERS:DulyattestedandpaginatedXeroxcopiesoftheindoorcasepaperswithhistorysheetandnursingchart/TPR/BP/RBSofMATUSHREEMATERNITYSURGICAL&GENERALNURSINGHOME..\n2.CostwisedetailedbreakupofInvestigationrequiredagainstthesubmittedbill\n3.DELAY:Letterfrominsured,statingreasonfordelayedintimation.",
"CLOSE_REASONS": "",
}
波乔班
import lombok.Data;
@Data
public class DetailsResponse {
@JsonProperty("MAJOR_DISEASES")
public String majorDiseases;
@JsonProperty("DEFICIENCIES")
public String deficiencies;
@JsonProperty("CLOSE_REASONS")
public String closeReasons;
}
JSONObject misObject=新JSONObject(结果)
String GetClaimsDetailsResult =misObject.get("GetClaimsDetailsResult").toString();
JSONObject getClaimsResultObj = new JSONObject(GetClaimsDetailsResult);
JSONArray misTable=(JSONArray) getClaimsResultObj.get("Table");
ObjectMapper objectMapper = new ObjectMapper();
myObjects = objectMapper.readValue(misTable.toString(), new TypeReference<List<MISClaimResponse>>(){});
这里result
是一个字符串,我从外部客户机getClaimsResultObj is JSONObject获取
我正在使用ObjectMapper转换为Object
但是得到InvalidFormatException
com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not deserialize value of type int from String "1.INDOORCASEPAPERS:DulyattestedandpaginatedXeroxcopiesoftheindoorcasepaperswithhistorysheetandnursingchart/TPR/BP/RBSofMATUSHREEMATERNITYSURGICAL&GENERALNURSINGHOME..
一个重要的问题是,我不能将输入json更改为第三方api
# 1 楼答案
你的json有问题。您需要创建有效的json
您可以使用以下代码进行测试: