The way to define a JS array is:
var arr = (); var arr = []; var New Array ();
How to stitch into a JSON field.
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" ><HTML> <HEAD> <TITLE> obj-to-JSON Demo & lt;/title> <meta name= "Generator" content= "EditPlus" > <meta name= "Author" content= "" > <meta name= "Ke Ywords "content=" "> <meta name=" Description "content=" "> functionStudent (sid,name,age,classinfo) { This. sid=SID; This. name=name; This. aeg=Age ; This. classinfo=ClassInfo; } functionClassInfo (classname,teacher) { This. classname=classname; This. teacher=teacher; } $(function(){ $("#testBut"). Click (function(){ varStudents =NewArray (); Arry=NewClassInfo (' Third grade class ', ' Xiang Zhengwei '); students[0]=NewStudent (2014001, ' Cai Zixu ', 23, Arry); students[1]=NewStudent (2014002, ' Zhang Bao ', 24, Arry); students[2]=NewStudent (2014003, ' Zhang Chin ', 33, Arry); varJsonstr=$.tojson (students); $("#showDiv"). Show (); $("#showDiv"). Text (JSONSTR); }); }); </script></HTML>
How to use JS to define an array, use JS to stitch the JSON field