1、有如下Json串需要解析成本地对象(实为京东开普勒业绩订单请求返回的json串):
String串:
result:{"jd_kpl_open_unionservice_queryCommisions_response":{"message":"SUCCESS","totalNum":null,"result":[{"plus":0,"orderDate":1532427881000,"sourceEmt":14,"orderEmt":2,"unionId":88888888,"finishDate":1532498450000,"orderStatus":1,"balance":2,"parentId":77769735208,"skuResVoList":[{"subUnionId":null,"payPrice":10.9,"promotionType":2,"skuClearStatus":1,"allianceUnionId":-1,"dSku":2,"subSideProportion":90.0,"skuId":4425729,"clearStatus":1,"commission":0.27,"allianceCommission":0.027,"subsidyParty":"1","subSideCommission":0.243,"subSideType":2,"skuNum":1,"spreadType":2,"skuName":"秀山米豆腐","subsidyCommission":0.027,"orderStatus":1,"spType":1,"trafficProviderCommission":0.0,"ruleType":0,"allianceProportion":10.0,"commissionRate":2.5,"promotionCont":1,"refStatus":0,"cosPrice":10.9,"unionTrafficType":89,"adTrafficType":89,"skuReturnNum":0,"yn":1,"trafficProviderName":"","trafficProviderUnionId":0,"trafficProviderProportion":0.0}],"refStatus":0,"clearStatus":1,"returnStatus":1,"spId":0,"yn":1,"split":2,"orderId":555555},{"plus":0,"orderDate":1532427881000,"sourceEmt":14,"orderEmt":2,"unionId":88888888,"finishDate":1532498579000,"orderStatus":1,"balance":2,"parentId":77769735208,"skuResVoList":[{"subUnionId":null,"payPrice":26.8,"promotionType":2,"skuClearStatus":1,"allianceUnionId":-1,"dSku":2,"subSideProportion":90.0,"skuId":2517940,"clearStatus":1,"commission":0.67,"allianceCommission":0.067,"subsidyParty":"1","subSideCommission":0.603,"subSideType":2,"skuNum":2,"spreadType":2,"skuName":"秀山绿豆粉","subsidyCommission":0.067,"orderStatus":1,"spType":1,"trafficProviderCommission":0.0,"ruleType":0,"allianceProportion":10.0,"commissionRate":2.5,"promotionCont":1,"refStatus":0,"cosPrice":26.8,"unionTrafficType":89,"adTrafficType":89,"skuReturnNum":0,"yn":1,"trafficProviderName":"","trafficProviderUnionId":0,"trafficProviderProportion":0.0},{"subUnionId":null,"payPrice":44.88,"promotionType":2,"skuClearStatus":1,"allianceUnionId":-1,"dSku":2,"subSideProportion":90.0,"skuId":3018363,"clearStatus":1,"commission":1.12,"allianceCommission":0.112,"subsidyParty":"1","subSideCommission":1.008,"subSideType":2,"skuNum":2,"spreadType":2,"skuName":"秀山油粑粑","subsidyCommission":0.112,"orderStatus":1,"spType":1,"trafficProviderCommission":0.0,"ruleType":0,"allianceProportion":10.0,"commissionRate":2.5,"promotionCont":1,"refStatus":0,"cosPrice":44.88,"unionTrafficType":89,"adTrafficType":89,"skuReturnNum":0,"yn":1,"trafficProviderName":"","trafficProviderUnionId":0,"trafficProviderProportion":0.0},{"subUnionId":null,"payPrice":38.8,"promotionType":2,"skuClearStatus":1,"allianceUnionId":-1,"dSku":2,"subSideProportion":90.0,"skuId":2518087,"clearStatus":1,"commission":0.97,"allianceCommission":0.097,"subsidyParty":"1","subSideCommission":0.873,"subSideType":2,"skuNum":2,"spreadType":2,"skuName":"秀山羊肉粉","subsidyCommission":0.097,"orderStatus":1,"spType":1,"trafficProviderCommission":0.0,"ruleType":0,"allianceProportion":10.0,"commissionRate":2.5,"promotionCont":1,"refStatus":0,"cosPrice":38.8,"unionTrafficType":89,"adTrafficType":89,"skuReturnNum":0,"yn":1,"trafficProviderName":"","trafficProviderUnionId":0,"trafficProviderProportion":0.0}],"refStatus":0,"clearStatus":1,"returnStatus":1,"spId":0,"yn":1,"split":2,"orderId":666666}],"hasNext":false,"uuid":null,"code":"0"}}
在线转换为:
result: {
"jd_kpl_open_unionservice_queryCommisions_response": {
"message": "SUCCESS",
"totalNum": null,
"result": [{
"plus": 0,
"orderDate": 1532427881000,
"sourceEmt": 14,
"orderEmt": 2,
"unionId": 88888888,
"finishDate": 1532498450000,
"orderStatus": 1,
"balance": 2,
"parentId": 77769735208,
"skuResVoList": [{
"subUnionId": null,
"payPrice": 10.9,
"promotionType": 2,
"skuClearStatus": 1,
"allianceUnionId": -1,
"dSku": 2,
"subSideProportion": 90.0,
"skuId": 4425729,
"clearStatus": 1,
"commission": 0.27,
"allianceCommission": 0.027,
"subsidyParty": "1",
"subSideCommission": 0.243,
"subSideType": 2,
"skuNum": 1,
"spreadType": 2,
"skuName": "秀山米豆腐",
"subsidyCommission": 0.027,
"orderStatus": 1,
"spType": 1,
"trafficProviderCommission": 0.0,
"ruleType": 0,
"allianceProportion": 10.0,
"commissionRate": 2.5,
"promotionCont": 1,
"refStatus": 0,
"cosPrice": 10.9,
"unionTrafficType": 89,
"adTrafficType": 89,
"skuReturnNum": 0,
"yn": 1,
"trafficProviderName": "",
"trafficProviderUnionId": 0,
"trafficProviderProportion": 0.0
}],
"refStatus": 0,
"clearStatus": 1,
"returnStatus": 1,
"spId": 0,
"yn": 1,
"split": 2,
"orderId": 555555
}, {
"plus": 0,
"orderDate": 1532427881000,
"sourceEmt": 14,
"orderEmt": 2,
"unionId": 88888888,
"finishDate": 1532498579000,
"orderStatus": 1,
"balance": 2,
"parentId": 77769735208,
"skuResVoList": [{
"subUnionId": null,
"payPrice": 26.8,
"promotionType": 2,
"skuClearStatus": 1,
"allianceUnionId": -1,
"dSku": 2,
"subSideProportion": 90.0,
"skuId": 2517940,
"clearStatus": 1,
"commission": 0.67,
"allianceCommission": 0.067,
"subsidyParty": "1",
"subSideCommission": 0.603,
"subSideType": 2,
"skuNum": 2,
"spreadType": 2,
"skuName": "秀山绿豆粉",
"subsidyCommission": 0.067,
"orderStatus": 1,
"spType": 1,
"trafficProviderCommission": 0.0,
"ruleType": 0,
"allianceProportion": 10.0,
"commissionRate": 2.5,
"promotionCont": 1,
"refStatus": 0,
"cosPrice": 26.8,
"unionTrafficType": 89,
"adTrafficType": 89,
"skuReturnNum": 0,
"yn": 1,
"trafficProviderName": "",
"trafficProviderUnionId": 0,
"trafficProviderProportion": 0.0
}, {
"subUnionId": null,
"payPrice": 44.88,
"promotionType": 2,
"skuClearStatus": 1,
"allianceUnionId": -1,
"dSku": 2,
"subSideProportion": 90.0,
"skuId": 3018363,
"clearStatus": 1,
"commission": 1.12,
"allianceCommission": 0.112,
"subsidyParty": "1",
"subSideCommission": 1.008,
"subSideType": 2,
"skuNum": 2,
"spreadType": 2,
"skuName": "秀山油粑粑",
"subsidyCommission": 0.112,
"orderStatus": 1,
"spType": 1,
"trafficProviderCommission": 0.0,
"ruleType": 0,
"allianceProportion": 10.0,
"commissionRate": 2.5,
"promotionCont": 1,
"refStatus": 0,
"cosPrice": 44.88,
"unionTrafficType": 89,
"adTrafficType": 89,
"skuReturnNum": 0,
"yn": 1,
"trafficProviderName": "",
"trafficProviderUnionId": 0,
"trafficProviderProportion": 0.0
}, {
"subUnionId": null,
"payPrice": 38.8,
"promotionType": 2,
"skuClearStatus": 1,
"allianceUnionId": -1,
"dSku": 2,
"subSideProportion": 90.0,
"skuId": 2518087,
"clearStatus": 1,
"commission": 0.97,
"allianceCommission": 0.097,
"subsidyParty": "1",
"subSideCommission": 0.873,
"subSideType": 2,
"skuNum": 2,
"spreadType": 2,
"skuName": "秀山羊肉粉",
"subsidyCommission": 0.097,
"orderStatus": 1,
"spType": 1,
"trafficProviderCommission": 0.0,
"ruleType": 0,
"allianceProportion": 10.0,
"commissionRate": 2.5,
"promotionCont": 1,
"refStatus": 0,
"cosPrice": 38.8,
"unionTrafficType": 89,
"adTrafficType": 89,
"skuReturnNum": 0,
"yn": 1,
"trafficProviderName": "",
"trafficProviderUnionId": 0,
"trafficProviderProportion": 0.0
}],
"refStatus": 0,
"clearStatus": 1,
"returnStatus": 1,
"spId": 0,
"yn": 1,
"split": 2,
"orderId": 666666
}],
"hasNext": false,
"uuid": null,
"code": "0"
}
}
result: {
"jd_kpl_open_unionservice_queryCommisions_response": {
"message": "SUCCESS",
"totalNum": null,
"result": [{
"plus": 0,
"orderDate": 1532427881000,
"sourceEmt": 14,
"orderEmt": 2,
"unionId": 88888888,
"finishDate": 1532498450000,
"orderStatus": 1,
"balance": 2,
"parentId": 77769735208,
"skuResVoList": [{
"subUnionId": null,
"payPrice": 10.9,
"promotionType": 2,
"skuClearStatus": 1,
"allianceUnionId": -1,
"dSku": 2,
"subSideProportion": 90.0,
"skuId": 4425729,
"clearStatus": 1,
"commission": 0.27,
"allianceCommission": 0.027,
"subsidyParty": "1",
"subSideCommission": 0.243,
"subSideType": 2,
"skuNum": 1,
"spreadType": 2,
"skuName": "秀山米豆腐",
"subsidyCommission": 0.027,
"orderStatus": 1,
"spType": 1,
"trafficProviderCommission": 0.0,
"ruleType": 0,
"allianceProportion": 10.0,
"commissionRate": 2.5,
"promotionCont": 1,
"refStatus": 0,
"cosPrice": 10.9,
"unionTrafficType": 89,
"adTrafficType": 89,
"skuReturnNum": 0,
"yn": 1,
"trafficProviderName": "",
"trafficProviderUnionId": 0,
"trafficProviderProportion": 0.0
}],
"refStatus": 0,
"clearStatus": 1,
"returnStatus": 1,
"spId": 0,
"yn": 1,
"split": 2,
"orderId": 555555
}, {
"plus": 0,
"orderDate": 1532427881000,
"sourceEmt": 14,
"orderEmt": 2,
"unionId": 88888888,
"finishDate": 1532498579000,
"orderStatus": 1,
"balance": 2,
"parentId": 77769735208,
"skuResVoList": [{
"subUnionId": null,
"payPrice": 26.8,
"promotionType": 2,
"skuClearStatus": 1,
"allianceUnionId": -1,
"dSku": 2,
"subSideProportion": 90.0,
"skuId": 2517940,
"clearStatus": 1,
"commission": 0.67,
"allianceCommission": 0.067,
"subsidyParty": "1",
"subSideCommission": 0.603,
"subSideType": 2,
"skuNum": 2,
"spreadType": 2,
"skuName": "秀山绿豆粉",
"subsidyCommission": 0.067,
"orderStatus": 1,
"spType": 1,
"trafficProviderCommission": 0.0,
"ruleType": 0,
"allianceProportion": 10.0,
"commissionRate": 2.5,
"promotionCont": 1,
"refStatus": 0,
"cosPrice": 26.8,
"unionTrafficType": 89,
"adTrafficType": 89,
"skuReturnNum": 0,
"yn": 1,
"trafficProviderName": "",
"trafficProviderUnionId": 0,
"trafficProviderProportion": 0.0
}, {
"subUnionId": null,
"payPrice": 44.88,
"promotionType": 2,
"skuClearStatus": 1,
"allianceUnionId": -1,
"dSku": 2,
"subSideProportion": 90.0,
"skuId": 3018363,
"clearStatus": 1,
"commission": 1.12,
"allianceCommission": 0.112,
"subsidyParty": "1",
"subSideCommission": 1.008,
"subSideType": 2,
"skuNum": 2,
"spreadType": 2,
"skuName": "秀山油粑粑",
"subsidyCommission": 0.112,
"orderStatus": 1,
"spType": 1,
"trafficProviderCommission": 0.0,
"ruleType": 0,
"allianceProportion": 10.0,
"commissionRate": 2.5,
"promotionCont": 1,
"refStatus": 0,
"cosPrice": 44.88,
"unionTrafficType": 89,
"adTrafficType": 89,
"skuReturnNum": 0,
"yn": 1,
"trafficProviderName": "",
"trafficProviderUnionId": 0,
"trafficProviderProportion": 0.0
}, {
"subUnionId": null,
"payPrice": 38.8,
"promotionType": 2,
"skuClearStatus": 1,
"allianceUnionId": -1,
"dSku": 2,
"subSideProportion": 90.0,
"skuId": 2518087,
"clearStatus": 1,
"commission": 0.97,
"allianceCommission": 0.097,
"subsidyParty": "1",
"subSideCommission": 0.873,
"subSideType": 2,
"skuNum": 2,
"spreadType": 2,
"skuName": "秀山羊肉粉",
"subsidyCommission": 0.097,
"orderStatus": 1,
"spType": 1,
"trafficProviderCommission": 0.0,
"ruleType": 0,
"allianceProportion": 10.0,
"commissionRate": 2.5,
"promotionCont": 1,
"refStatus": 0,
"cosPrice": 38.8,
"unionTrafficType": 89,
"adTrafficType": 89,
"skuReturnNum": 0,
"yn": 1,
"trafficProviderName": "",
"trafficProviderUnionId": 0,
"trafficProviderProportion": 0.0
}],
"refStatus": 0,
"clearStatus": 1,
"returnStatus": 1,
"spId": 0,
"yn": 1,
"split": 2,
"orderId": 666666
}],
"hasNext": false,
"uuid": null,
"code": "0"
}
}
二、由此可见有三个对象,于是创建三个对象:
1.QueryCommisionsResponse .java
package com.imooc.utils.testjson;
import java.util.List;
/**
*
* @类名称 QueryCommisionsResponse.java
* @类描述 <pre>业绩查询返回对象</pre>
* @作者
* @创建时间 2018年7月30日 上午10:35:04
* @版本 1.00
*
* @修改记录
* <pre>
* 版本 修改人 修改日期 修改内容描述
* ----------------------------------------------
* 1.00 yw 2018年7月30日
* ----------------------------------------------
* </pre>
*/
public class QueryCommisionsResponse implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
//返回码 0:接口调用成功 1:接口调用失败
private int code;
//描述信息
private String message;
//记录总数
private Long totalNum;
//返回结果
private List<OrderResVo> result;
//是否存在下一个条目 按照unionId查询时,该值是正确的
private boolean hasNext;
/**
* @return the code
*/
public int getCode() {
return code;
}
/**
* @param code the code to set
*/
public void setCode(int code) {
this.code = code;
}
/**
* @return the message
*/
public String getMessage() {
return message;
}
/**
* @param message the message to set
*/
public void setMessage(String message) {
this.message = message;
}
/**
* @return the totalNum
*/
public Long getTotalNum() {
return totalNum;
}
/**
* @param totalNum the totalNum to set
*/
public void setTotalNum(Long totalNum) {
this.totalNum = totalNum;
}
/**
* @return the result
*/
public List<OrderResVo> getResult() {
return result;
}
/**
* @param result the result to set
*/
public void setResult(List<OrderResVo> result) {
this.result = result;
}
/**
* @return the hasNext
*/
public boolean isHasNext() {
return hasNext;
}
/**
* @param hasNext the hasNext to set
*/
public void setHasNext(boolean hasNext) {
this.hasNext = hasNext;
}
/**
* @方法名称 toString
* @功能描述 <pre></pre>
* @作者 yw
* @创建时间 2018年7月30日 上午10:55:16
* @return
*/
@Override
public String toString() {
return "QueryCommisionsResponse [code=" + code + ", message=" + message
+ ", totalNum=" + totalNum + ", result=" + result
+ ", hasNext=" + hasNext + "]";
}
}
2.OrderResVo .java
package com.imooc.utils.testjson;
import java.util.List;
/**
*
* @类名称 OrderResVo.java
* @类描述 <pre>业绩查询返回的订单vo</pre>
* @作者
* @创建时间 2018年7月30日 上午10:41:18
* @版本 1.00
*
* @修改记录
* <pre>
* 版本 修改人 修改日期 修改内容描述
* ----------------------------------------------
* 1.00 yw 2018年7月30日
* ----------------------------------------------
* </pre>
*/
public class OrderResVo implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
//联盟ID
private long unionId;
//订单ID
private long orderId;
//推广位ID
private long spId;
//下单平台
private int sourceEmt;
//下单时间(兼容其他语言,精确到毫秒)
private long orderDate;
//订单完成时间(兼容其他语言,精确到毫秒)
private long finishDate;
//是否plus会员 1是,0不是
private int plus;
//是否拆单 1已拆单 2未拆单
private int split;
//1:已结算,2:未结算
private int balance;
//1未删除(有效),0删除(取消订单),-1:父单
private int yn;
//订单状态 0:已取消 1:已完成 2:未完成
private int orderStatus;
//作弊标示 0非作弊 50人工违规 其他值都是作弊
private int refStatus;
//订单清洗状态 1清洗正常 -1cookie不在有效期 -2校园订单 -3企消订单 -4团购订单 -5增值税
private int clearStatus;
//订单退货状态,1:未退货,2退货(退货:sku行购买的全部商品数和退货商品数一致的时候,接口就会认为该订单为退货状态,其他情况下算不算退货请调用方根据自己的业务自行处理)
private int returnStatus;
//sku 返回的列表
private List<SkuResVo> skuResVoList;
//父单ID
private long parentId;
//下单设备 1:PC,2:无线
private int orderEmt;
/**
* @return the unionId
*/
public long getUnionId() {
return unionId;
}
/**
* @param unionId the unionId to set
*/
public void setUnionId(long unionId) {
this.unionId = unionId;
}
/**
* @return the orderId
*/
public long getOrderId() {
return orderId;
}
/**
* @param orderId the orderId to set
*/
public void setOrderId(long orderId) {
this.orderId = orderId;
}
/**
* @return the spId
*/
public long getSpId() {
return spId;
}
/**
* @param spId the spId to set
*/
public void setSpId(long spId) {
this.spId = spId;
}
/**
* @return the sourceEmt
*/
public int getSourceEmt() {
return sourceEmt;
}
/**
* @param sourceEmt the sourceEmt to set
*/
public void setSourceEmt(int sourceEmt) {
this.sourceEmt = sourceEmt;
}
/**
* @return the orderDate
*/
public long getOrderDate() {
return orderDate;
}
/**
* @param orderDate the orderDate to set
*/
public void setOrderDate(long orderDate) {
this.orderDate = orderDate;
}
/**
* @return the finishDate
*/
public long getFinishDate() {
return finishDate;
}
/**
* @param finishDate the finishDate to set
*/
public void setFinishDate(long finishDate) {
this.finishDate = finishDate;
}
/**
* @return the plus
*/
public int getPlus() {
return plus;
}
/**
* @param plus the plus to set
*/
public void setPlus(int plus) {
this.plus = plus;
}
/**
* @return the split
*/
public int getSplit() {
return split;
}
/**
* @param split the split to set
*/
public void setSplit(int split) {
this.split = split;
}
/**
* @return the balance
*/
public int getBalance() {
return balance;
}
/**
* @param balance the balance to set
*/
public void setBalance(int balance) {
this.balance = balance;
}
/**
* @return the yn
*/
public int getYn() {
return yn;
}
/**
* @param yn the yn to set
*/
public void setYn(int yn) {
this.yn = yn;
}
/**
* @return the orderStatus
*/
public int getOrderStatus() {
return orderStatus;
}
/**
* @param orderStatus the orderStatus to set
*/
public void setOrderStatus(int orderStatus) {
this.orderStatus = orderStatus;
}
/**
* @return the refStatus
*/
public int getRefStatus() {
return refStatus;
}
/**
* @param refStatus the refStatus to set
*/
public void setRefStatus(int refStatus) {
this.refStatus = refStatus;
}
/**
* @return the clearStatus
*/
public int getClearStatus() {
return clearStatus;
}
/**
* @param clearStatus the clearStatus to set
*/
public void setClearStatus(int clearStatus) {
this.clearStatus = clearStatus;
}
/**
* @return the returnStatus
*/
public int getReturnStatus() {
return returnStatus;
}
/**
* @param returnStatus the returnStatus to set
*/
public void setReturnStatus(int returnStatus) {
this.returnStatus = returnStatus;
}
/**
* @return the skuResVoList
*/
public List<SkuResVo> getSkuResVoList() {
return skuResVoList;
}
/**
* @param skuResVoList the skuResVoList to set
*/
public void setSkuResVoList(List<SkuResVo> skuResVoList) {
this.skuResVoList = skuResVoList;
}
/**
* @return the parentId
*/
public long getParentId() {
return parentId;
}
/**
* @param parentId the parentId to set
*/
public void setParentId(long parentId) {
this.parentId = parentId;
}
/**
* @return the orderEmt
*/
public int getOrderEmt() {
return orderEmt;
}
/**
* @param orderEmt the orderEmt to set
*/
public void setOrderEmt(int orderEmt) {
this.orderEmt = orderEmt;
}
@Override
public String toString() {
return "OrderResVo [unionId=" + unionId + ", orderId=" + orderId + ", spId=" + spId + ", sourceEmt=" + sourceEmt
+ ", orderDate=" + orderDate + ", finishDate=" + finishDate + ", plus=" + plus + ", split=" + split
+ ", balance=" + balance + ", yn=" + yn + ", orderStatus=" + orderStatus + ", refStatus=" + refStatus
+ ", clearStatus=" + clearStatus + ", returnStatus=" + returnStatus + ", skuResVoList=" + skuResVoList
+ ", parentId=" + parentId + ", orderEmt=" + orderEmt + "]";
}
}
3、SkuResVo .java
package com.imooc.utils.testjson;
/**
*
* @类名称 SkuResVo.java
* @类描述 <pre></pre>
* @创建时间 2018年7月30日 上午10:49:46
* @版本 1.00
*
* @修改记录
* <pre>
* 版本 修改人 修改日期 修改内容描述
* ----------------------------------------------
* 1.00 yw 2018年7月30日
* ----------------------------------------------
* </pre>
*/
public class SkuResVo {
private long skuId ; // 商品ID
private String skuName ; // 商品名称
private long skuNum ; // 商品数量
private long skuReturnNum ; // 商品退货数量
private int subSideType ; // 分佣方类型(1:联盟平台,2:流量提供方,3:内容提供者)
private float subSideProportion ; // 分佣方的分佣比例
private float subSideCommission ; // 分佣方的分佣金额(兼容其他语言)
private String subsidyParty ; // 补贴方(数据格式: 1; 2; 1,2) (1:联盟平台,2:流量提供方)联盟平台和流量提供方同时补贴给一方,用英文逗号隔开
private float subsidyCommission ; // 补贴的佣金金额(兼容其他语言)
private long allianceUnionId ; // 联盟平台的联盟ID
private float allianceProportion ; // 联盟平台的分佣比例
private float allianceCommission ; // 联盟平台的分佣金额(兼容其他语言)
private long trafficProviderUnionId ; // 量提供方的联盟ID(发现频道,达人平台,明星衣橱等等)
private String trafficProviderName ; // 流量提供方的名称
private float trafficProviderProportion ; // 流量提供方的分佣比例
private float trafficProviderCommission ; // 流量提供方的分佣金额(兼容其他语言)
private float commission ; // 佣金(每条sku记录) 如果查询的是引用订单,表示预估佣金 如果查询的是业绩订单,表示实际佣金;最终获得的佣金=subSideProportion+allianceProportion
private float commissionRate ; // 计算佣金的比例, 如果查询引用订单,表示预估佣金比例 如果查询业绩订单,表示实际佣金比例
private int yn ; // 是否有效:1有效,0无效;
private int orderStatus ; // 订单状态: 0:已取消 1:已完成 2:未完成 6:等待确认收货(由第三方快递配送订单)
private int refStatus ; // 作弊标示: 0非作弊 50人工违规 其他值都是作弊
private int clearStatus ; // 订单清洗状态: 1清洗正常 -1cookie不在有效期 -2校园订单 -3企消订单 -4团购订单 -5增值税
private int skuClearStatus ; // sku清洗状态: 1清洗正常 其他非正常
private float payPrice ; // 付款金额(兼容其他语言), 如果查询的是引入订单,表示预估支付金额(值为:0) 如果查询的是业绩订单,表示实际支付金额
private float cosPrice ; // 计佣金额(兼容其他语言), 如果查询的是引入订单,表示预估计佣金额 如果查询的是业绩订单,表示实际计佣金额
private int adTrafficType ; // 6 cps,16cpc,17轻微店
private int unionTrafficType ; // 流量来源
private int promotionType ; // 推广方式
private int promotionCont ; // 推广内容
private int spreadType ; // 站内/站外/页面 1-站内,2-站外, 3-中间页/流量池
private int spType ; // 推广类型
private int dSku ; // 0:影响sku ,1:直接sku ,2:同店sku, 3:跨店sku
private int ruleType ; // 规则类型, 1、通用规则 2、定向规则 3、站长补贴、4:首单奖励、5.补充设置、 6:pop类目规则 //7:pop商品; //8:pop店铺基础、9:供应商类目规则、10:供应商商品、11供应商店铺基础、12采销类目规则、13采销商品 14:定向pop类目规则 15:定向pop商品; 16:定向pop店铺基础; 17:定向供应商类目规则 18:定向供应商商品; 19:定向供应商店铺基础; 20:定向采销类目规则 21:定向采销商品;
private String subUnionId ; // 子联盟ID
/**
* @return the skuId
*/
public long getSkuId() {
return skuId;
}
/**
* @param skuId the skuId to set
*/
public void setSkuId(long skuId) {
this.skuId = skuId;
}
/**
* @return the skuName
*/
public String getSkuName() {
return skuName;
}
/**
* @param skuName the skuName to set
*/
public void setSkuName(String skuName) {
this.skuName = skuName;
}
/**
* @return the skuNum
*/
public long getSkuNum() {
return skuNum;
}
/**
* @param skuNum the skuNum to set
*/
public void setSkuNum(long skuNum) {
this.skuNum = skuNum;
}
/**
* @return the skuReturnNum
*/
public long getSkuReturnNum() {
return skuReturnNum;
}
/**
* @param skuReturnNum the skuReturnNum to set
*/
public void setSkuReturnNum(long skuReturnNum) {
this.skuReturnNum = skuReturnNum;
}
/**
* @return the subSideType
*/
public int getSubSideType() {
return subSideType;
}
/**
* @param subSideType the subSideType to set
*/
public void setSubSideType(int subSideType) {
this.subSideType = subSideType;
}
/**
* @return the subSideProportion
*/
public float getSubSideProportion() {
return subSideProportion;
}
/**
* @param subSideProportion the subSideProportion to set
*/
public void setSubSideProportion(float subSideProportion) {
this.subSideProportion = subSideProportion;
}
/**
* @return the subSideCommission
*/
public float getSubSideCommission() {
return subSideCommission;
}
/**
* @param subSideCommission the subSideCommission to set
*/
public void setSubSideCommission(float subSideCommission) {
this.subSideCommission = subSideCommission;
}
/**
* @return the subsidyParty
*/
public String getSubsidyParty() {
return subsidyParty;
}
/**
* @param subsidyParty the subsidyParty to set
*/
public void setSubsidyParty(String subsidyParty) {
this.subsidyParty = subsidyParty;
}
/**
* @return the subsidyCommission
*/
public float getSubsidyCommission() {
return subsidyCommission;
}
/**
* @param subsidyCommission the subsidyCommission to set
*/
public void setSubsidyCommission(float subsidyCommission) {
this.subsidyCommission = subsidyCommission;
}
/**
* @return the allianceUnionId
*/
public long getAllianceUnionId() {
return allianceUnionId;
}
/**
* @param allianceUnionId the allianceUnionId to set
*/
public void setAllianceUnionId(long allianceUnionId) {
this.allianceUnionId = allianceUnionId;
}
/**
* @return the allianceProportion
*/
public float getAllianceProportion() {
return allianceProportion;
}
/**
* @param allianceProportion the allianceProportion to set
*/
public void setAllianceProportion(float allianceProportion) {
this.allianceProportion = allianceProportion;
}
/**
* @return the allianceCommission
*/
public float getAllianceCommission() {
return allianceCommission;
}
/**
* @param allianceCommission the allianceCommission to set
*/
public void setAllianceCommission(float allianceCommission) {
this.allianceCommission = allianceCommission;
}
/**
* @return the trafficProviderUnionId
*/
public long getTrafficProviderUnionId() {
return trafficProviderUnionId;
}
/**
* @param trafficProviderUnionId the trafficProviderUnionId to set
*/
public void setTrafficProviderUnionId(long trafficProviderUnionId) {
this.trafficProviderUnionId = trafficProviderUnionId;
}
/**
* @return the trafficProviderName
*/
public String getTrafficProviderName() {
return trafficProviderName;
}
/**
* @param trafficProviderName the trafficProviderName to set
*/
public void setTrafficProviderName(String trafficProviderName) {
this.trafficProviderName = trafficProviderName;
}
/**
* @return the trafficProviderProportion
*/
public float getTrafficProviderProportion() {
return trafficProviderProportion;
}
/**
* @param trafficProviderProportion the trafficProviderProportion to set
*/
public void setTrafficProviderProportion(float trafficProviderProportion) {
this.trafficProviderProportion = trafficProviderProportion;
}
/**
* @return the trafficProviderCommission
*/
public float getTrafficProviderCommission() {
return trafficProviderCommission;
}
/**
* @param trafficProviderCommission the trafficProviderCommission to set
*/
public void setTrafficProviderCommission(float trafficProviderCommission) {
this.trafficProviderCommission = trafficProviderCommission;
}
/**
* @return the commission
*/
public float getCommission() {
return commission;
}
/**
* @param commission the commission to set
*/
public void setCommission(float commission) {
this.commission = commission;
}
/**
* @return the commissionRate
*/
public float getCommissionRate() {
return commissionRate;
}
/**
* @param commissionRate the commissionRate to set
*/
public void setCommissionRate(float commissionRate) {
this.commissionRate = commissionRate;
}
/**
* @return the yn
*/
public int getYn() {
return yn;
}
/**
* @param yn the yn to set
*/
public void setYn(int yn) {
this.yn = yn;
}
/**
* @return the orderStatus
*/
public int getOrderStatus() {
return orderStatus;
}
/**
* @param orderStatus the orderStatus to set
*/
public void setOrderStatus(int orderStatus) {
this.orderStatus = orderStatus;
}
/**
* @return the refStatus
*/
public int getRefStatus() {
return refStatus;
}
/**
* @param refStatus the refStatus to set
*/
public void setRefStatus(int refStatus) {
this.refStatus = refStatus;
}
/**
* @return the clearStatus
*/
public int getClearStatus() {
return clearStatus;
}
/**
* @param clearStatus the clearStatus to set
*/
public void setClearStatus(int clearStatus) {
this.clearStatus = clearStatus;
}
/**
* @return the skuClearStatus
*/
public int getSkuClearStatus() {
return skuClearStatus;
}
/**
* @param skuClearStatus the skuClearStatus to set
*/
public void setSkuClearStatus(int skuClearStatus) {
this.skuClearStatus = skuClearStatus;
}
/**
* @return the payPrice
*/
public float getPayPrice() {
return payPrice;
}
/**
* @param payPrice the payPrice to set
*/
public void setPayPrice(float payPrice) {
this.payPrice = payPrice;
}
/**
* @return the cosPrice
*/
public float getCosPrice() {
return cosPrice;
}
/**
* @param cosPrice the cosPrice to set
*/
public void setCosPrice(float cosPrice) {
this.cosPrice = cosPrice;
}
/**
* @return the adTrafficType
*/
public int getAdTrafficType() {
return adTrafficType;
}
/**
* @param adTrafficType the adTrafficType to set
*/
public void setAdTrafficType(int adTrafficType) {
this.adTrafficType = adTrafficType;
}
/**
* @return the unionTrafficType
*/
public int getUnionTrafficType() {
return unionTrafficType;
}
/**
* @param unionTrafficType the unionTrafficType to set
*/
public void setUnionTrafficType(int unionTrafficType) {
this.unionTrafficType = unionTrafficType;
}
/**
* @return the promotionType
*/
public int getPromotionType() {
return promotionType;
}
/**
* @param promotionType the promotionType to set
*/
public void setPromotionType(int promotionType) {
this.promotionType = promotionType;
}
/**
* @return the promotionCont
*/
public int getPromotionCont() {
return promotionCont;
}
/**
* @param promotionCont the promotionCont to set
*/
public void setPromotionCont(int promotionCont) {
this.promotionCont = promotionCont;
}
/**
* @return the spreadType
*/
public int getSpreadType() {
return spreadType;
}
/**
* @param spreadType the spreadType to set
*/
public void setSpreadType(int spreadType) {
this.spreadType = spreadType;
}
/**
* @return the spType
*/
public int getSpType() {
return spType;
}
/**
* @param spType the spType to set
*/
public void setSpType(int spType) {
this.spType = spType;
}
/**
* @return the dSku
*/
public int getdSku() {
return dSku;
}
/**
* @param dSku the dSku to set
*/
public void setdSku(int dSku) {
this.dSku = dSku;
}
/**
* @return the ruleType
*/
public int getRuleType() {
return ruleType;
}
/**
* @param ruleType the ruleType to set
*/
public void setRuleType(int ruleType) {
this.ruleType = ruleType;
}
/**
* @return the subUnionId
*/
public String getSubUnionId() {
return subUnionId;
}
/**
* @param subUnionId the subUnionId to set
*/
public void setSubUnionId(String subUnionId) {
this.subUnionId = subUnionId;
}
@Override
public String toString() {
return "SkuResVo [skuId=" + skuId + ", skuName=" + skuName + ", skuNum=" + skuNum + ", skuReturnNum="
+ skuReturnNum + ", subSideType=" + subSideType + ", subSideProportion=" + subSideProportion
+ ", subSideCommission=" + subSideCommission + ", subsidyParty=" + subsidyParty + ", subsidyCommission="
+ subsidyCommission + ", allianceUnionId=" + allianceUnionId + ", allianceProportion="
+ allianceProportion + ", allianceCommission=" + allianceCommission + ", trafficProviderUnionId="
+ trafficProviderUnionId + ", trafficProviderName=" + trafficProviderName
+ ", trafficProviderProportion=" + trafficProviderProportion + ", trafficProviderCommission="
+ trafficProviderCommission + ", commission=" + commission + ", commissionRate=" + commissionRate
+ ", yn=" + yn + ", orderStatus=" + orderStatus + ", refStatus=" + refStatus + ", clearStatus="
+ clearStatus + ", skuClearStatus=" + skuClearStatus + ", payPrice=" + payPrice + ", cosPrice="
+ cosPrice + ", adTrafficType=" + adTrafficType + ", unionTrafficType=" + unionTrafficType
+ ", promotionType=" + promotionType + ", promotionCont=" + promotionCont + ", spreadType=" + spreadType
+ ", spType=" + spType + ", dSku=" + dSku + ", ruleType=" + ruleType + ", subUnionId=" + subUnionId
+ "]";
}
}
三、以上准备工作完成之后,开始解析了,下面才是关键代码:
自己之前对解析json这块怎么熟悉,解析了半天没解析出OrderResVo对象来,首层可解。于是对比了能解析的其他类似的串,才发现多了一行jd_kpl_open_unionservice_queryCommisions_response。于是想到要么通过key拿到value,要么切割,显然,通过key拿比较靠谱。所以如下代码,先通过key jd_kpl_open_unionservice_queryCommisions_response拿到value,再解析这个串即可正常解析。
package com.imooc.utils.testjson;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
/**
*
* @类名称 JsonUtil.java
* @类描述 <pre>JsonUtil测试代码</pre>
* @作者
* @创建时间 2018年7月31日 上午12:35:56
* @版本 1.00
*
* @修改记录
* <pre>
* 版本 修改人 修改日期 修改内容描述
* ----------------------------------------------
* 1.00 xingsfdz 2018年7月31日
* ----------------------------------------------
* </pre>
*/
public class JsonUtil {
public static void main(String[] args) {
String str = "{'jd_kpl_open_unionservice_queryCommisions_response':{'message':'SUCCESS','totalNum':null,'result':[{'plus':0,'orderDate':1532427881000,'sourceEmt':14,'orderEmt':2,'unionId':88888888,'finishDate':1532498450000,'orderStatus':1,'balance':2,'parentId':77769735208,'skuResVoList':[{'subUnionId':null,'payPrice':10.9,'promotionType':2,'skuClearStatus':1,'allianceUnionId':-1,'dSku':2,'subSideProportion':90.0,'skuId':4425729,'clearStatus':1,'commission':0.27,'allianceCommission':0.027,'subsidyParty':'1','subSideCommission':0.243,'subSideType':2,'skuNum':1,'spreadType':2,'skuName':'秀山米豆腐','subsidyCommission':0.027,'orderStatus':1,'spType':1,'trafficProviderCommission':0.0,'ruleType':0,'allianceProportion':10.0,'commissionRate':2.5,'promotionCont':1,'refStatus':0,'cosPrice':10.9,'unionTrafficType':89,'adTrafficType':89,'skuReturnNum':0,'yn':1,'trafficProviderName':'','trafficProviderUnionId':0,'trafficProviderProportion':0.0}],'refStatus':0,'clearStatus':1,'returnStatus':1,'spId':0,'yn':1,'split':2,'orderId':555555},{'plus':0,'orderDate':1532427881000,'sourceEmt':14,'orderEmt':2,'unionId':88888888,'finishDate':1532498579000,'orderStatus':1,'balance':2,'parentId':77769735208,'skuResVoList':[{'subUnionId':null,'payPrice':26.8,'promotionType':2,'skuClearStatus':1,'allianceUnionId':-1,'dSku':2,'subSideProportion':90.0,'skuId':2517940,'clearStatus':1,'commission':0.67,'allianceCommission':0.067,'subsidyParty':'1','subSideCommission':0.603,'subSideType':2,'skuNum':2,'spreadType':2,'skuName':'秀山绿豆粉','subsidyCommission':0.067,'orderStatus':1,'spType':1,'trafficProviderCommission':0.0,'ruleType':0,'allianceProportion':10.0,'commissionRate':2.5,'promotionCont':1,'refStatus':0,'cosPrice':26.8,'unionTrafficType':89,'adTrafficType':89,'skuReturnNum':0,'yn':1,'trafficProviderName':'','trafficProviderUnionId':0,'trafficProviderProportion':0.0},{'subUnionId':null,'payPrice':44.88,'promotionType':2,'skuClearStatus':1,'allianceUnionId':-1,'dSku':2,'subSideProportion':90.0,'skuId':3018363,'clearStatus':1,'commission':1.12,'allianceCommission':0.112,'subsidyParty':'1','subSideCommission':1.008,'subSideType':2,'skuNum':2,'spreadType':2,'skuName':'秀山油粑粑','subsidyCommission':0.112,'orderStatus':1,'spType':1,'trafficProviderCommission':0.0,'ruleType':0,'allianceProportion':10.0,'commissionRate':2.5,'promotionCont':1,'refStatus':0,'cosPrice':44.88,'unionTrafficType':89,'adTrafficType':89,'skuReturnNum':0,'yn':1,'trafficProviderName':'','trafficProviderUnionId':0,'trafficProviderProportion':0.0},{'subUnionId':null,'payPrice':38.8,'promotionType':2,'skuClearStatus':1,'allianceUnionId':-1,'dSku':2,'subSideProportion':90.0,'skuId':2518087,'clearStatus':1,'commission':0.97,'allianceCommission':0.097,'subsidyParty':'1','subSideCommission':0.873,'subSideType':2,'skuNum':2,'spreadType':2,'skuName':'秀山羊肉粉','subsidyCommission':0.097,'orderStatus':1,'spType':1,'trafficProviderCommission':0.0,'ruleType':0,'allianceProportion':10.0,'commissionRate':2.5,'promotionCont':1,'refStatus':0,'cosPrice':38.8,'unionTrafficType':89,'adTrafficType':89,'skuReturnNum':0,'yn':1,'trafficProviderName':'','trafficProviderUnionId':0,'trafficProviderProportion':0.0}],'refStatus':0,'clearStatus':1,'returnStatus':1,'spId':0,'yn':1,'split':2,'orderId':666666}],'hasNext':false,'uuid':null,'code':'0'}}";
List<OrderResVo> list = jsonUtil(str);
for(OrderResVo bean : list){
System.out.println(bean.toString());
}
}
public static List<OrderResVo> jsonUtil(String jsonStr){
JSONObject jsonObj= JSONObject.parseObject(jsonStr);
String resultList= jsonObj.getString("jd_kpl_open_unionservice_queryCommisions_response");
QueryCommisionsResponse root = JSON.parseObject(resultList, QueryCommisionsResponse.class);
List<OrderResVo> orderList = new ArrayList<OrderResVo>();
for (int i = 0; i < root.getResult().size(); i++) {
OrderResVo bean = root.getResult().get(i);
orderList.add(bean);
// System.out.println(root.getResult().get(i).getOrderId());
}
return orderList;
}
}
以上我使用的阿里的fastjson,附上pom依赖:
<!-- fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.28</version>
</dependency>
输出结果:
OrderResVo [unionId=88888888, orderId=555555, spId=0, sourceEmt=14, orderDate=1532427881000, finishDate=1532498450000, plus=0, split=2, balance=2, yn=1, orderStatus=1, refStatus=0, clearStatus=1, returnStatus=1, skuResVoList=[SkuResVo [skuId=4425729, skuName=秀山米豆腐, skuNum=1, skuReturnNum=0, subSideType=2, subSideProportion=90.0, subSideCommission=0.243, subsidyParty=1, subsidyCommission=0.027, allianceUnionId=-1, allianceProportion=10.0, allianceCommission=0.027, trafficProviderUnionId=0, trafficProviderName=, trafficProviderProportion=0.0, trafficProviderCommission=0.0, commission=0.27, commissionRate=2.5, yn=1, orderStatus=1, refStatus=0, clearStatus=1, skuClearStatus=1, payPrice=10.9, cosPrice=10.9, adTrafficType=89, unionTrafficType=89, promotionType=2, promotionCont=1, spreadType=2, spType=1, dSku=2, ruleType=0, subUnionId=null]], parentId=77769735208, orderEmt=2]
OrderResVo [unionId=88888888, orderId=666666, spId=0, sourceEmt=14, orderDate=1532427881000, finishDate=1532498579000, plus=0, split=2, balance=2, yn=1, orderStatus=1, refStatus=0, clearStatus=1, returnStatus=1, skuResVoList=[SkuResVo [skuId=2517940, skuName=秀山绿豆粉, skuNum=2, skuReturnNum=0, subSideType=2, subSideProportion=90.0, subSideCommission=0.603, subsidyParty=1, subsidyCommission=0.067, allianceUnionId=-1, allianceProportion=10.0, allianceCommission=0.067, trafficProviderUnionId=0, trafficProviderName=, trafficProviderProportion=0.0, trafficProviderCommission=0.0, commission=0.67, commissionRate=2.5, yn=1, orderStatus=1, refStatus=0, clearStatus=1, skuClearStatus=1, payPrice=26.8, cosPrice=26.8, adTrafficType=89, unionTrafficType=89, promotionType=2, promotionCont=1, spreadType=2, spType=1, dSku=2, ruleType=0, subUnionId=null], SkuResVo [skuId=3018363, skuName=秀山油粑粑, skuNum=2, skuReturnNum=0, subSideType=2, subSideProportion=90.0, subSideCommission=1.008, subsidyParty=1, subsidyCommission=0.112, allianceUnionId=-1, allianceProportion=10.0, allianceCommission=0.112, trafficProviderUnionId=0, trafficProviderName=, trafficProviderProportion=0.0, trafficProviderCommission=0.0, commission=1.12, commissionRate=2.5, yn=1, orderStatus=1, refStatus=0, clearStatus=1, skuClearStatus=1, payPrice=44.88, cosPrice=44.88, adTrafficType=89, unionTrafficType=89, promotionType=2, promotionCont=1, spreadType=2, spType=1, dSku=2, ruleType=0, subUnionId=null], SkuResVo [skuId=2518087, skuName=秀山羊肉粉, skuNum=2, skuReturnNum=0, subSideType=2, subSideProportion=90.0, subSideCommission=0.873, subsidyParty=1, subsidyCommission=0.097, allianceUnionId=-1, allianceProportion=10.0, allianceCommission=0.097, trafficProviderUnionId=0, trafficProviderName=, trafficProviderProportion=0.0, trafficProviderCommission=0.0, commission=0.97, commissionRate=2.5, yn=1, orderStatus=1, refStatus=0, clearStatus=1, skuClearStatus=1, payPrice=38.8, cosPrice=38.8, adTrafficType=89, unionTrafficType=89, promotionType=2, promotionCont=1, spreadType=2, spType=1, dSku=2, ruleType=0, subUnionId=null]], parentId=77769735208, orderEmt=2]
over 完美解析!谨以此笔记一下。
标签:set,return,复杂,int,void,private,json,解析,public From: https://blog.51cto.com/u_16152740/6431808