@RequestBody jackson解析複雜的傳入值的一個坑;jackson解析迭代數組;jackson多重數組;jakson數組

來源:互聯網
上載者:User

標籤:解析   一個   col   ToJson   span   and   ide   技術分享   hide   

一、實際開發的一個問題。

      傳入一個json數組,數組中還嵌套數組,運用springboot+Jpa架構,@RequestBody註解傳入資料

     Controller

1  @ApiOperation(value = "添加訂單", notes = "添加訂單", httpMethod = "POST")2     @RequestMapping("/addOrder")3     public BaseResource addOrder(@RequestBody BaseSingleList baseSingleList) {4         log.info("controller傳入資料:" + gson.toJson(baseSingleList));5 6         return orderService.addOrder(baseSingleList);7 8 }
View Code

    傳入對象的json格式

 1 { 2     "singleOrderList": [ 3         { 4             "orderName": "wyy", 5             "orderPhone": "186683812781", 6             "contact": "wyy", 7             "telephony": "187738122781", 8             "provinceId": 123, 9             "cityId": 1-302,10             "regionId": 19930203,11             "address": "33363",12             "userId": "32689d13465242dfad62ee1cdbf34d887",13             "serieId": "94",14             "trueTime": "2018-12-02",15             "overTime": "2019-12-01",16             "monthlyRent": 5000,17             "dateCount": 18,18             "packageId": "34ea0a3fb9a4496bab90488727ad6c57a09b",19             "total": "3000000",20             "ModularIdNum": [21                 {22                     "itemId": "b20f1c33256ae64ad576bec51e85d821eae1",23                     "modularNum": 124                 }25             ],26             "isRentAndSell": 11110,27             "applicationArea": null,28             "remark": null,29             "instruPurpose": null30         }31     ]32 }
View Code

二、傳入後總是接收不到
      

"ModularIdNum": [
{
"itemId": "b20f1c33256ae64ad576bec51e85d821eae1",
"modularNum": 1
}
]
這段數組的值,本來以為是@RequestBody無法解析問題,最後發現是欄位的大小寫問題

ModularIdNum 建立在實體類中,是不能大寫的,需要小寫modularIdNum

"modularIdNum": [
{
"itemId": "b20f1c33256ae64ad576bec51e85d821eae1",
"modularNum": 1
}
]

實體類對應

 

 

 

 

 



@RequestBody jackson解析複雜的傳入值的一個坑;jackson解析迭代數組;jackson多重數組;jakson數組

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.