我正在使用一个宁静的API,该API对服务调用给出以下响应,

[
{
id=123,
 cloudStatusTimestamp=2019-01-21T15:45:06.823,
 cloudStatusCode=null,
cloudStatusMessage=300: PDF generated successfully,
 cloudStatusComments=Inbound invoice,Reference: 123
}
,{
id=436,
 cloudStatusTimestamp=2019-02-21T05:45:06.423,
 cloudStatusCode=null,
 cloudStatusMessage=300: PDF generated successfully,
cloudStatusComments=Inbound invoice, Reference: 456
}
]


我想解析上述对Java对象的响应。我手动尝试通过replacing '=' by ':'将响应转换为JSON,并将键和值对括在引号中,但由于某些值之间存在','而无法正常工作(cloudStatusComments = Inbound invoice,Reference:456)。请分享您的评论。

最佳答案

JSON格式不正确。
格式应如下所示:

  [
  {
  "id":123,
 "cloudStatusTimestamp":"2019-01-21T15:45:06.823",
 "cloudStatusCode":null,
"cloudStatusMessage":"300: PDF generated successfully",
 "cloudStatusComments":"Inbound invoice",
 "Reference": 123
},
{
  "id":436,
 "cloudStatusTimestamp":"2019-02-21T05:45:06.423",
 "cloudStatusCode":null,
 "cloudStatusMessage":"300: PDF generated successfully",
"cloudStatusComments":"Inbound invoice, Reference: 456"
}
]


希望这可以帮助你

09-11 20:05