json字符串转化成含多层list集合的对象
json
适用于现代 C++ 的 JSON。
项目地址:https://gitcode.com/gh_mirrors/js/json
免费下载资源
·
返回待解析报文
"DATA" : [ {
"infoSource" : "IN",
"actOrderId" : 110718608,
"orderAppId" : "3200130001",
"orderAppCustomCategory" : null,
"channelLevel1" : 0,
"channelLevel2" : 0,
"channelLevel3" : 0,
"channelLevel4" : null,
"orderStatus" : 2,
"orderStatusDesc" : "已支付(待发货) ",
"payStatus" : 2,
"refundStatus" : 0,
"expressStatus" : 2,
"clossStatus" : 0,
"createTime" : "20151028101923",
"payTime" : "20151028102000",
"userId" : 177383800,
"andUserId" : null,
"showUrl" : null,
"shopId" : "11224193",
"shopName" : "避风塘",
"hasRefund" : 0,
"payOnDelivery" : 0,
"goodsInfos" : [ {
"goodsId" : 78259824,
"goodsName" : "食堂活动-自提商品",
"goodsImage" : "p_1911291824.jpg",
"price" : 1,
"count" : 3,
"goodsDetail" : null,
"goodsDesc" : null,
"isVirtual" : 0,
"payCount" : 3,
"goodsVersion" : "40170570"
} ],
"expressInfos" : [ {
"expressCompanyId" : 10000,
"expressNo" : null,
"receiverName" : null,
"address" : null,
"phoneNumber" : null,
"receiveTime" : "20151028103413",
"expressCost" : 0,
"status" : 2
} ],
代码转化示例:
// JSON转换
JSONObject jsonObj = JSONObject.fromObject(goodsJson);
Map<String, Class> classMap = new HashMap<String, Class>();
classMap.put("DATA", DataInfoDto.class);
classMap.put("goodsInfos", GoodsInfoDto.class);
classMap.put("expressInfos", ExpressInfoDto.class);
// 将JSON转换成DeliveryInfoDto
DeliveryInfoDto delivery = (DeliveryInfoDto) JSONObject.toBean(jsonObj,
DeliveryInfoDto.class, classMap);
创建相关实体类:
package com.justinmobile.lticket.domain.dto;
import java.io.Serializable;
import java.util.List;
/**
* 返回提货订单信息
* @author cm
*/
@SuppressWarnings("serial")
public class DeliveryInfoDto implements Serializable
{
public String TOTALROW;
public List<DataInfoDto> DATA;
public DeliveryInfoDto(){
super();
}
public String getTOTALROW()
{
return TOTALROW;
}
public void setTOTALROW(String tOTALROW)
{
TOTALROW = tOTALROW;
}
public List<DataInfoDto> getDATA()
{
return DATA;
}
public void setDATA(List<DataInfoDto> dATA)
{
DATA = dATA;
}
}
package com.justinmobile.lticket.domain.dto;
import java.io.Serializable;
import java.util.List;
/**
* 返回提货订单信息
* @author cm
*/
@SuppressWarnings("serial")
public class DataInfoDto implements Serializable
{
public String infoSource;
public Long actOrderId;
public String orderAppId;
public String orderAppCustomCategory;
public int channelLevel1;
public int channelLevel2;
public int channelLevel3;
public String channelLevel4;
public int orderStatus;
public String orderStatusDesc;
public int payStatus;
public int refundStatus;
public int expressStatus;
public int clossStatus;
public String createTime;
public String payTime;
public Long userId;
public String andUserId;
public String showUrl;
public String shopId;
public String shopName;
public int hasRefund;
public int payOnDelivery;
public List<GoodsInfoDto> goodsInfos;
public List<ExpressInfoDto> expressInfos;
public int totalPay;
public String refundUrl;
public DataInfoDto(){
super();
}
public String getInfoSource()
{
return infoSource;
}
public void setInfoSource(String infoSource)
{
this.infoSource = infoSource;
}
public Long getActOrderId()
{
return actOrderId;
}
public void setActOrderId(Long actOrderId)
{
this.actOrderId = actOrderId;
}
public String getOrderAppId()
{
return orderAppId;
}
public void setOrderAppId(String orderAppId)
{
this.orderAppId = orderAppId;
}
public String getOrderAppCustomCategory()
{
return orderAppCustomCategory;
}
public void setOrderAppCustomCategory(String orderAppCustomCategory)
{
this.orderAppCustomCategory = orderAppCustomCategory;
}
public int getChannelLevel1()
{
return channelLevel1;
}
public void setChannelLevel1(int channelLevel1)
{
this.channelLevel1 = channelLevel1;
}
public int getChannelLevel2()
{
return channelLevel2;
}
public void setChannelLevel2(int channelLevel2)
{
this.channelLevel2 = channelLevel2;
}
public int getChannelLevel3()
{
return channelLevel3;
}
public void setChannelLevel3(int channelLevel3)
{
this.channelLevel3 = channelLevel3;
}
public String getChannelLevel4()
{
return channelLevel4;
}
public void setChannelLevel4(String channelLevel4)
{
this.channelLevel4 = channelLevel4;
}
public int getOrderStatus()
{
return orderStatus;
}
public void setOrderStatus(int orderStatus)
{
this.orderStatus = orderStatus;
}
public String getOrderStatusDesc()
{
return orderStatusDesc;
}
public void setOrderStatusDesc(String orderStatusDesc)
{
this.orderStatusDesc = orderStatusDesc;
}
public int getPayStatus()
{
return payStatus;
}
public void setPayStatus(int payStatus)
{
this.payStatus = payStatus;
}
public int getRefundStatus()
{
return refundStatus;
}
public void setRefundStatus(int refundStatus)
{
this.refundStatus = refundStatus;
}
public int getExpressStatus()
{
return expressStatus;
}
public void setExpressStatus(int expressStatus)
{
this.expressStatus = expressStatus;
}
public int getClossStatus()
{
return clossStatus;
}
public void setClossStatus(int clossStatus)
{
this.clossStatus = clossStatus;
}
public String getCreateTime()
{
return createTime;
}
public void setCreateTime(String createTime)
{
this.createTime = createTime;
}
public String getPayTime()
{
return payTime;
}
public void setPayTime(String payTime)
{
this.payTime = payTime;
}
public Long getUserId()
{
return userId;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public String getAndUserId()
{
return andUserId;
}
public void setAndUserId(String andUserId)
{
this.andUserId = andUserId;
}
public String getShowUrl()
{
return showUrl;
}
public void setShowUrl(String showUrl)
{
this.showUrl = showUrl;
}
public String getShopId()
{
return shopId;
}
public void setShopId(String shopId)
{
this.shopId = shopId;
}
public String getShopName()
{
return shopName;
}
public void setShopName(String shopName)
{
this.shopName = shopName;
}
public int getHasRefund()
{
return hasRefund;
}
public void setHasRefund(int hasRefund)
{
this.hasRefund = hasRefund;
}
public int getPayOnDelivery()
{
return payOnDelivery;
}
public void setPayOnDelivery(int payOnDelivery)
{
this.payOnDelivery = payOnDelivery;
}
public List<GoodsInfoDto> getGoodsInfos()
{
return goodsInfos;
}
public void setGoodsInfos(List<GoodsInfoDto> goodsInfos)
{
this.goodsInfos = goodsInfos;
}
public List<ExpressInfoDto> getExpressInfos()
{
return expressInfos;
}
public void setExpressInfos(List<ExpressInfoDto> expressInfos)
{
this.expressInfos = expressInfos;
}
public int getTotalPay()
{
return totalPay;
}
public void setTotalPay(int totalPay)
{
this.totalPay = totalPay;
}
public String getRefundUrl()
{
return refundUrl;
}
public void setRefundUrl(String refundUrl)
{
this.refundUrl = refundUrl;
}
}
package com.justinmobile.lticket.domain.dto;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 商品信息DTO
* @author cm
*
*/
@SuppressWarnings("serial")
public class GoodsInfoDto implements Serializable
{
public Long goodsId;
public String goodsName;
public String goodsImage;
public BigDecimal price;
public int count;
public String goodsDetail;
public String goodsDesc;
public int isVirtual;
public int payCount;
public String goodsVersion;
public GoodsInfoDto(){
super();
}
public Long getGoodsId()
{
return goodsId;
}
public void setGoodsId(Long goodsId)
{
this.goodsId = goodsId;
}
public String getGoodsName()
{
return goodsName;
}
public void setGoodsName(String goodsName)
{
this.goodsName = goodsName;
}
public String getGoodsImage()
{
return goodsImage;
}
public void setGoodsImage(String goodsImage)
{
this.goodsImage = goodsImage;
}
public BigDecimal getPrice()
{
return price;
}
public void setPrice(BigDecimal price)
{
this.price = price;
}
public int getCount()
{
return count;
}
public void setCount(int count)
{
this.count = count;
}
public String getGoodsDetail()
{
return goodsDetail;
}
public void setGoodsDetail(String goodsDetail)
{
this.goodsDetail = goodsDetail;
}
public String getGoodsDesc()
{
return goodsDesc;
}
public void setGoodsDesc(String goodsDesc)
{
this.goodsDesc = goodsDesc;
}
public int getIsVirtual()
{
return isVirtual;
}
public void setIsVirtual(int isVirtual)
{
this.isVirtual = isVirtual;
}
public int getPayCount()
{
return payCount;
}
public void setPayCount(int payCount)
{
this.payCount = payCount;
}
public String getGoodsVersion()
{
return goodsVersion;
}
public void setGoodsVersion(String goodsVersion)
{
this.goodsVersion = goodsVersion;
}
}
package com.justinmobile.lticket.domain.dto;
import java.io.Serializable;
/**
* 物流信息DTO
* @author cm
*
*/
@SuppressWarnings("serial")
public class ExpressInfoDto implements Serializable
{
public Long expressCompanyId;
public String expressNo;
public String receiverName;
public String address;
public String phoneNumber;
public String receiveTime;
public int expressCost;
public int status;
public ExpressInfoDto(){
super();
}
public Long getExpressCompanyId()
{
return expressCompanyId;
}
public void setExpressCompanyId(Long expressCompanyId)
{
this.expressCompanyId = expressCompanyId;
}
public String getExpressNo()
{
return expressNo;
}
public void setExpressNo(String expressNo)
{
this.expressNo = expressNo;
}
public String getReceiverName()
{
return receiverName;
}
public void setReceiverName(String receiverName)
{
this.receiverName = receiverName;
}
public String getPhoneNumber()
{
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber)
{
this.phoneNumber = phoneNumber;
}
public String getReceiveTime()
{
return receiveTime;
}
public void setReceiveTime(String receiveTime)
{
this.receiveTime = receiveTime;
}
public int getExpressCost()
{
return expressCost;
}
public void setExpressCost(int expressCost)
{
this.expressCost = expressCost;
}
public int getStatus()
{
return status;
}
public void setStatus(int status)
{
this.status = status;
}
public String getAddress()
{
return address;
}
public void setAddress(String address)
{
this.address = address;
}
}
GitHub 加速计划 / js / json
41.72 K
6.61 K
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e
4 个月前
8c391e04
7 个月前
更多推荐
已为社区贡献1条内容
所有评论(0)