fastjson error solution details com.alibaba.fastjson.JSONException: syntax error, expect {, actual EOF, pos 1410

reason:

      The array passed by the front-end is too complicated, but this problem occurs. The front-end uses vue axios to send requests, and the back-end java receives the code to realize the separation of front and back ends.

The backend receives fastjson to receive json, and performs business processing. The status of the backend Controller:

 1 /**
 2      * 
 3      * <p>
 4      * <p>添加订单
 5      *
 6      * @return Object
 7      */
 8     @ResponseBody
 9     @RequestMapping(value = "/addOrder", //
10             method = RequestMethod.POST)
11     public Object addOrder(@RequestBody BaseSingleList baseSingleList) {
12 
13         return orderService.addOrder(baseSingleList);
14 
15  }
View Code

The front end sends the json style

 1 {
 2     "singleOrderList":[
 3         {
 4             "orderName":"唐1",
 5             "orderPhone":"13245124512",
 6             "contact":"送",
 7             "telephony":"7845120231111",
 8             "provinceId":31,
 9             "cityId":3101,
10             "regionId":310108,
11             "address":"默认添加唐",
12             "userId":"c6f53705451b497580ef093c0ff5",
13             "serieId":"1",
14             "trueTime":"2018-04-27",
15             "overTime":"2019-04-27",
16             "monthlyRent":6000,
17             "dateCount":12,
18             "packageId":"3e449fb4b4a489fce1475c4577fb6",
19             "applicationArea":"ssswww",
20             "total":"219000",
21             "ModularIdNum":[
22                 {
23                     "itemId":"9b744dc99e2904d96ab1af5",
24                     "modularNum":3
25                 }
26             ]
27         },
28         {
29             "orderName":"唐1",
30             "orderPhone":"13245124512",
31             "contact":"送",
32             "telephony":"7845120231111",
33             "provinceId":31,
34             "cityId":3101,
35             "regionId":310108,
36             "address":"Add Tang by default" 37,
             "userId":"b4f13b97580ef093c0ff5",
38             "serieId":"1",
39             "trueTime":"2018-04-27",
40             "overTime":"2019-04-27",
41             "monthlyRent":6000,
42             "dateCount":12,
43             "packageId":"3b4b4a489fce1475c4577fb6",
44             "applicationArea":"ssswww",
45             "total":"219000",
46             "ModularIdNum":[
47                 {
48                     "itemId":"09932da9b744dc99e295",
49                     "modularNum":3
50                 }
51             ]
52         }
53     ]
54 }
View Code

solution:

       The controller normally passes in the data, decomposes the data and resends the business logic in the serviceImpl layer

 1 /**
 2      * 下订单
 3      *
 4      * @param baseSingleList
 5      * @return Object
 6      */
 7     @Override
 8     public Object addOrder(BaseSingleList baseSingleList) {
 9 
10         String lineArray = JSONArray.toJSONString(baseSingleList);
11         HashMap parseMap = JSON.parseObject(lineArray,HashMap.class);
12 
13         List<SingleOrder> singleOrderList = JSON.parseArray(JSON.parseObject(lineArray).getString("singleOrderList"),SingleOrder.class);
14         
15          for(SingleOrder singleOrder : singleOrderList){
16 
17              System.out.println(singleOrder.getUserId());
18          }
19 }
View Code

 

  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324985368&siteId=291194637