myjson
<script type="text/javascript">
function test(){
var str = '{ "name": "Violet", "occupation": "character" }';
var obj = eval('(' + str + ')');
alert(obj.toJSONString());
}
function newForm(){
var newform = document.createElement("FORM");
document.body.appendChild(newform);
newform.method = "post";
//createNewFormElement(emsform, "user", xxx);
//createNewFormElement(emsform, "password", xxxxx);
var url = "home";
var t1 = document.getElementById("t1").value;
var t2 = document.getElementById("t2").value;
var t3 = document.getElementById("t3").value;
var t4 = document.getElementById("t4").value;
var myObject = new Object(); //创建对象
var obindings = new Array();
var oFirst = new Object();
var oSecond = new Object();
var oThird = new Object();
oFirst.t1 = t1;
oFirst.t2 = t2;
oFirst.t3 = t3;
obindings[0] = oFirst;
obindings[1] = oSecond;
obindings[2] = oThird;
//将obindings数组设置为myObject的bindings成员
myObject.bindings = obindings;
var jsonstr = myObject.toJSONString();
newform.action = "home?" + "jsonstr=" + jsonstr;
newform.target = "";
newform.submit();
}
function createNewFormElement(inputForm, elementName, elementValue)
{
var newElement = document.createElement("input");
newElement.setAttribute("name",elementName);
newElement.setAttribute("type","hidden");
newElement.setAttribute("value",elementValue);
inputForm.appendChild(newElement);
return newElement;
}
</script>
JSONObject jso = JSONObject.fromObject(jsonstr);
http://developer.51cto.com/art/200906/129090.htm
http://topic.csdn.net/u/20071102/08/7599ac02-830d-4bf3-b799-c30dc0f4509b.html