2017년 12월 4일 월요일

json만들기

var obj = "${topData}"
alert(obj);
//var objParse = JSON.parse(obj);

alert(obj.top1);

var jsonMap  = $.stringify(obj);

$.each( jsonMap, function( key, value ) {
  alert( key + ": " + value );
});

/*
var empMap = '${topData}';
//here is the example value of map in javascript which i see while debugging
//var empMap = {emp1_100=[com.Employee@5b7b4bc5], emp2...

for (var key in empMap) {
    alert(key + ': ' + empMap[key]);
}*/

        ArrayList<HashMap<String, String>> targetList = new ArrayList<HashMap<String, String>>();
        HashMap<String, String> targetDataMap = new HashMap<String, String>();
        targetDataMap.put("id", "1");
        targetDataMap.put("name", "kim seungpil");
        targetDataMap.put("age", "38");
        targetList.add(targetDataMap);
       
        HashMap<String, ArrayList<HashMap<String, String>>> middleDataMap =
        new HashMap<String, ArrayList<HashMap<String, String>>>();
        middleDataMap.put("test1", targetList);
       
        HashMap<String, HashMap<String, ArrayList<HashMap<String, String>>>> topDataMap =
        new HashMap<String, HashMap<String, ArrayList<HashMap<String, String>>>>();
       
        topDataMap.put("top1", middleDataMap);
        topDataMap.put("top2", middleDataMap);
       
        //langSel.add("\"en\"", true);
       
model.addAttribute("topData", topDataMap);

댓글 없음:

댓글 쓰기