js jsonArray 만들기

긴 말 없이 바로 코드에 올랐다.
1. 프론트 데스크 생성:
		var jsonstr="[]";
			var jsonarray = eval('('+jsonstr+')');
			
			var formdata1 = {
					"activeproid" : activeproid[0].value,
					"activeproPrice" : activeproPrice[0].value,
					"activeproKucun" : activeproKucun[0].value,
					"activeproXiangou" : activeproXiangou[0].value,
					"activeproStart" : activeproStart[0].value,
					"activeproend" : activeproend[0].value
				};
			var formdata2 = {
					"activeproid" : activeproid[1].value,
					"activeproPrice" : activeproPrice[1].value,
					"activeproKucun" : activeproKucun[1].value,
					"activeproXiangou" : activeproXiangou[1].value,
					"activeproStart" : activeproStart[1].value,
					"activeproend" : activeproend[1].value
				};
	
			jsonarray.push(formdata1);
			jsonarray.push(formdata2);
				
			var formdata = {
					"postMes":jsonarray,
					"actId":actId
				};
			
			$.ajax({
		        type: "POST",
		        url: "url",
		        contentType: "application/json; charset=utf-8",
		        data: JSON.stringify(formdata),
		        dataType: "json",
		        success: function (message) {
		        	
		        },
		        error: function (message) {
		            $("#request-process-patent").html("      !");
		        }
		  

2. 배경 해석:
                JsonNode in = request().body().asJson();//        
		Logger.info("       " + in.toString());
		String actId = in.get("actId").textValue();
		Iterator trades = in.findValue("postMes").elements();
	
		while (trades.hasNext()) {
			JsonNode trade = trades.next();
			String activeproid = trade.get("activeproid").textValue();
			Logger.info("id:" + activeproid);
			String activeproPrice = trade.get("activeproPrice").textValue();
			Logger.info("  :" + activeproPrice);
			。。。
			
		}

좋은 웹페이지 즐겨찾기