Analytical data type nested json

Some time ago wrote a deeply nested json data objects, took a half-day strength, record it

Similar multiple front-end data Taobao condition search, json key-value data type is a nested array

Ajax pass value for the front end

function searfunc (ARR) {
         // ARR search as the search button after output 
        the console.log (ARR); 
        $ .ajax ({ 
            URL: '/ conprob / TitleList' , 
            type: 'POST' , 
            contentType: "file application / JSON " , 
            Traditional: to true , 
            the async: to true , 
            Data: the JSON.stringify (ARR),

Background controller layer receives data types JSONArray

  @RequestMapping(value = "titleList",produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object titleList(@RequestBody JSONArray jsonParam){
    
    }

split the service layer parsed

for(int i = 0;i<jsonParam.size();i++){
            JSONObject jsonObject=jsonParam.getJSONObject(i);
            String key = jsonObject.getString("key");
            JSONArray jsonArray=jsonObject.getJSONArray("val");
            List<String> valList = new ArrayList<>();
            for(int j = 0;j<jsonArray.size();j++){
                String val = jsonArray.get(j).toString();
            }
        }

In this online Baidu borrow to summarize, personally I feel that the summary is in place

Guess you like

Origin www.cnblogs.com/xiaowangxiao/p/11324528.html
Recommended