java json 对象 序列化_json - 将Json字符串反序列化为对象Java - 堆栈内存溢出

我正在正确地以字符串形式获取响应。 但是,当我尝试将其建模为模型类时,我无法获取值。 我猜我还没有正确序列化它。

我尝试了其他一些示例,但是它说:

无法反序列化START_OBJECT中的实例

我的JsonString响应:

{

"basicAccount": {

"acctId": 101600000,

"edjAccountPreferredName": "MARET, RODEL",

"faNumber": "000000",

"branchNumber": 0000,

"relationshipId": 00000000,

"customerNo": 88888888,

"primaryContactId": 14532683,

"accountCloseDate": null,

"authFormReceivedInd": "Y",

"accountServiceTypeCode": null,

"accountServiceTypeStatusCode": null,

"accountOwnershipRuleId": 321,

"inheritedAccountFlag": "N",

"ownershipTypeKey": "US_FD_T",

"accountMailingAddressId": 53828912,

"vendorAccountId": "262826",

"ownershipTypeDescription": "hghfdbgh hjksd ",

"countryCode": null,

"accountOpenDate": "1995-08-11"

},

"trustAccount": false

}

我的模型类别:/

public class BasicAccount implements Serializable {

@JsonProperty("basicAccount")

@JsonInclude(Include.NON_NULL)

private List basicAccount;

List basicAccounts;*/

@JsonProperty("acctId")

private BigDecimal acctId;

@JsonProperty("edjAccountPreferredName")

private String edjAccountPreferredName;

@JsonProperty("faNumber")

private String faNumber;

@JsonProperty("branchNumber")

private Integer branchNumber;

@JsonProperty("relationshipId")

private BigDecimal relationshipId;

@JsonProperty("customerNo")

private BigDecimal customerNo;

@JsonProperty("primaryContactId")

private BigDecimal primaryContactId;

@JsonProperty("accountCloseDate")

private String accountCloseDate;

@JsonProperty("authFormReceivedInd")

private String authFormReceivedInd;

@JsonProperty("accountServiceTypeCode")

private String accountServiceTypeCode;

@JsonProperty("accountServiceTypeStatusCode")

private String accountServiceTypeStatusCode;

@JsonProperty("accountOwnershipRuleId")

private Short accountOwnershipRuleId;

@JsonProperty("inheritedAccountFlag")

private String inheritedAccountFlag;

@JsonProperty("ownershipTypeKey")

private String ownershipTypeKey;

@JsonProperty("accountMailingAddressId")

private BigDecimal accountMailingAddressId;

@JsonProperty("vendorAccountId")

private String vendorAccountId;

@JsonProperty("ownershipTypeDescription")

private String ownershipTypeDescription;

@JsonProperty("countryCode")

private String countryCode;

@JsonProperty("accountOpenDate")

private String accountOpenDate;

@JsonInclude(Include.NON_NULL)

private boolean trustAccount;

@Override

public String toString() {

return ToStringBuilder.reflectionToString(this);

}

}

以下是用于反序列化的代码:

String basiStr = restTemplate.exchange(targetUrl,HttpMethod.GET,requestEntity, new ParameterizedTypeReference(){}).getBody();

BasicAccount myProduct = objectMapper.readValue(basiStr,new TypeReference(){});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值