赞
踩
目录
https://github.com/Yellow213/ConvenienceTools
* 优点:自动解析,方便快捷,且维护性较好。
* 缺点:那种方法是将所有的东西都要解析出来,其实好几个类压根没用用的,也就是说那几个类其实是垃圾类,但是如果不写,那么就会报错。
上代码:
- import com.dist.model.*;
- import net.sf.json.JSONObject;
- import net.sf.json.JsonConfig;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.junit.runners.JUnit4;
-
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Objects;
-
- /**
- * @author hh
- * @date 2019/02/28
- * @方法一:通过解析json,并转存进去实体类
- * 优点:自动解析,方便快捷,且维护性较好。
- * 缺点:那种方法是将所有的东西都要解析出来,其实好几个类压根没用用的,也就是说那几个类其实是垃圾类,但是如果不写,那么就会报错。
- */
- @RunWith(JUnit4.class)
- public class DriverTestClass {
- @Test
- public void test01()throws Exception{
- //(1)当获取到一条信息的时候,通过层层的解析,获得json数据
- String str ="{\"orderCode\":\"346\",\"userName\":\"136\",\"customerName\":\"小明\",\"provinceCode\":\"190\",\"cityCode\":\"000\",\"districtCode\":\"000\",\"customerAddress\":\"广东省广州市\",\"mobNum\":\"136\",\"orderSaleTime\":\"2019-02-01 23:04:26\",\"evaluationMark\":\"0\",\"invoiceHead\":\"小明\",\"orderTotalStatus\":\"30\",\"provinceName\":\"广东省\",\"cityName\":\"广州市\",\"districtName\":\"xX区\",\"sellerOrdRemark\":\"E3\",\"buyerOrdRemark\":\"\",\"invoiceType\":\"02\",\"invoice\":\"\",\"vatTaxpayerNumber\":\"\",\"registerAddress\":\"\",\"registerPhone\":\"\",\"bank\":\"\",\"account\":\"\",\"invoiceRecipientAddress\":\"\",\"invoiceRecipientName\":\"\",\"invoiceRecipientPhone\":\"\",\"invoiceRecipientHandPhone\":\"\",\"payType\":\"\",\"payTotalAmount\":\"\",\"needinvoiceflag\":\"Y\",\"isCanModifyTransportFee\":\"N\",\"guideAccountNo\":\"\",\"orderTime\":\"2019-02-01 23:02:53\",\"colorMarkFlags\":\"2\",\"phoneNum\":\"\",\"zipCode\":\"\",\"deliveryArea\":\"0200499\",\"detailAddress\":\"世外桃源\",\"countMoney\":\"490.00000\",\"sumDonationAmt\":\"0.00\",\"orderDetail\":[{\"productCode\":\"10668919671\",\"productName\":\"周生�?(CHOW SANG SANG)时尚黄金K金链18K金项�? 百搭素链 04800N18KY定价 40厘米\",\"unitPrice\":\"530.00000\",\"payAmount\":\"490.00000\",\"saleNum\":\"1.00000\",\"orderLineStatus\":\"30\",\"transportFee\":\"0.00000\",\"returnOrderFlag\":\"0\",\"coupontotalMoney\":\"40.00000\",\"vouchertotalMoney\":\"\",\"invCode\":\
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。