用于设置和获取值的Java文件。我已将boId
设置为第一个:
if(etsBuildOrder != null){
buildOrder.setBoId(etsBuildOrder.getBoId());
buildOrder.setName(etsBuildOrder.getName());
buildOrder.setFactory(etsBuildOrder.getFactory());
buildOrder.setStatus(etsBuildOrder.getStatus());
buildOrder.setIssued(etsBuildOrder.getIssued());
buildOrder.setTeam(etsBuildOrder.getTeam());
buildOrder.setType(etsBuildOrder.getType());
buildOrder.setBuildId(etsBuildOrder.getBuildRequestId());
buildOrder.setPartNumber(etsBuildOrder.getPartNumber());
buildOrder.setProductCode(etsBuildOrder.getProductCode());
buildOrder.setSpecialInstructions(etsBuildOrder.getSpecialInstructions());
buildOrder.setBoCreationDate(RestWsUtil.convertDateToString(etsBuildOrder.getCreationDate(), Constants.SIMPLE_DATE_FORMAT_DATE_ONLY));
buildOrder.setBoModifiedDate(RestWsUtil.convertDateToString(etsBuildOrder.getModifiedDate(), Constants.SIMPLE_DATE_FORMAT_DATE_ONLY));
buildOrder.setChangeHistory(etsBuildOrder.getChangeHistory());
}
JSON返回格式。 boId
不在JSON的开头:
{
"name": "TLO9009",
"factory": "L-Slider",
"type": null,
"boCreationDate": "18 Apr 2018",
"boModifiedDate": "18 Apr 2018",
"status": "Pending Approval",
"team": null,
"partNumber": null,
"specialInstructions": "Special Inst",
"changeHistory": "Pending ApprovalWed Apr 18 10:14:06 SGT 2018",
"productCode": null,
"issued": null,
"multifeature": null,
"buildId": 0,
"boId": 141
}
JSON应该如何返回。我希望JSON像这样返回:
{
"boId": 141
"name": "TLO9009",
"factory": "L-Slider",
"type": null,
"boCreationDate": "18 Apr 2018",
"boModifiedDate": "18 Apr 2018",
"status": "Pending Approval",
"team": null,
"partNumber": null,
"specialInstructions": "Special Inst",
"changeHistory": "Pending ApprovalWed Apr 18 10:14:06 SGT 2018",
"productCode": null,
"issued": null,
"multifeature": null,
"buildId": 0
}
我是JAVA的新手,非常感谢帮助。谢谢。
答案 0 :(得分:2)
这是不可能的,也没有必要。两个JSON对象都是相同的,没有顺序。
对象是名称/值对的无序集。对象以
{
(左大括号)开头,以}
(右大括号)结束。每个名称后跟:
(冒号),名称/值对由,
(逗号)分隔。