javascript - Convert JSON to java script -
can provide java script below json. tried in many way, not add field "set"
{ "student":[ "set", [ { "name":"abcd", "id":"1234" } ] ] }
so javascript
variable object
having property/key name student of array
type. student has 2 elements set string
, object
, other element array
, has element of object
type. element has 2 properties/keys name , id.
var required = {}; required.student = []; required.student.push("set"); var innerarray = []; var innerobj = {}; innerobj.name = "abcd"; innerobj.id = "1234"; innerarray.push(innerobj); required.student.push(innerarray); document.write('<pre> ' + json.stringify(required,0, 3) + '</pre>');
Comments
Post a Comment