将包含数组的json字符串转为包含集合的javabean

贴核心的代码

			Map<String, Class> classMap = new HashMap<String, Class>();
			classMap.put("orderList", OrderListBean.class);
			classMap.put("subOrderList", SubOrderListBean.class);
			classMap.put("merchList", MerchListBean.class);
			CodeInputBean bean = (CodeInputBean) JSONObject.toBean(
					JSONObject.fromObject(json), CodeInputBean.class, classMap);

bean的代码:

这里的核心就是list类型的要放入map中


public class OrderListBean {
	
	private String merNo;
	private String orderId;
	private String adv;
	private String orderMsg;
	private String merchSrc;
	private String msgType;
	private List<SubOrderListBean> subOrderList;
}



public class SubOrderListBean {
	
	private List<MerchListBean> merchList;//数量amount
	private String subOrderId;//子订单号
	private BigDecimal orderAmt;
	private BigDecimal paymentAmt;
	private BigDecimal unpayAmt;
	private String merchName;//商品名称
	private String merchId; //商城商品编号
	private String merchCode;//核销平台 导入商品编号
	private String merchDecription;//商品描述<短信信息>
	private String createDate;
	private String endDate;
}



public class MerchListBean {
      private String merchOrderId;
}

参考的写自己的代码就行了。


你可能感兴趣的:(将包含数组的json字符串转为包含集合的javabean)