1. Create a JSON object
var objjson = [];
2.JSON Value Assignment
var Objjson = Jquery.parsejson (' [{PID ': 1, Cnt ': 1}] ');
Objjson.push (Jquery.parsejson (' {"PID": ' + IPID + ', "Cnt": ' + icnt + '} '));
3.JSON Take value
/**
* JSON tool
/
var jsonutil = (function () {return
{
/**
* * Gets a single value in JSON */
GetValue: function (jsonobject,name) {
var value = "";
$.each (Jsonobject,function (n,v) {
if (name = = N) {
value = V;
return false;
}
});
return value;
},
/**
* Gets the name in the JSON as an array
returns
/Getnames:function (jsonobject) {
var names = [];
$.each (Jsonobject,function (n,v) {
names.push (n);
});
Return names
},
/**
* Create JSON object
/createjsonobject:function () {
This.jsonobectarr = [];
}
}
}) ();
4.jquery Cache
$ ("div"). Data ("blah"); Undefined
$ ("div"). Data ("blah", "hello"); Blah set to Hello
$ ("div"). Data ("blah"); Hello
$ ("div"). Data ("blah",); Set to
$ ("div"). Data ("blah");
$ ("div"). Removedata ("blah"); Remove blah
$ ("div"). Data ("blah"); Undefined
$ ("div"). Data ("Test", {first:16, Last: "pizza!"});
$ ("div"). Data ("Test"). //16;
$ ("div"). Data ("Test"). Last //pizza!;
5. Array
var arr = new Array ();
arr[0]=0; Assigned value
Arr.push (88);//Assignment