SPListItem is spliced into Json format, and splistitem is spliced into json format
You can try to convert SPList. Items to Json format. Public static string GetJsonFormSplistItem (SPListItem item, string [] strArr) {string json = "{"; for (int I = 0; I <item. parentList. fields. count-1; I ++) {string fieldName = item. parentList. fields [I]. internalName; ArrayList ar = new ArrayList (); // instantiate an ArrayList ar. addRange (strArr); // assign the array to the Arraylist object if (ar. contains (fieldName) {if (item [I]! = Null) {json + = "\" "+ fieldName +" \ ": \" "+ item [I]. toString () + "\", ";}else {json + =" \ "" + fieldName + "\":\"\",";}}} json + = "},"; return json;} public string [] problemRiskArr = {"ProjectName", "ProblemBody", "AffectDegree", "User", "CountermoveBody ", "Status "};
How to Use jquery to splice json data on a jsp page
I don't know what you want to do.
Jquery is a js function library running on the browser. After json is parsed by the browser, It is a javascript literal (or an object ). Are you saying that splicing converts two json data into an object? I don't think this is necessary at all. If you need to get two json files at the same time, you can directly merge the two requests into one on the server side, so that the speed of using only one request is faster.
It is also feasible if you have to obtain the object twice and then splice it into an object.
Function callBack (json ){
Write the code for processing the final json
}
$. GetJSON ("url1", function (json1) {// obtain the first json
$. GetJSON ("url2", function (json2) {// obtain the second json from the callback function
Var key;
For (key in json2) {// traverse the second json object and add it to the first json object
Json1 [key] = json2 [key];
};
CallBack (json1 );
// Process the final json object
});
});
Jquery Concatenates the Json format and outputs The result. If you want to run it correctly, how can you write it?
Isn't it good for you to write this? How can you write it?
Var data = {"persons": [{"sex": "male", "name": "" },{ "sex": "female ", "name": "Xiao Xu" },{ "sex": "male", "name": "Xiao Ming" },{ "sex": "female", "name ": "Xiao Zhang" },{ "sex": "male", "name": "Xiao Li" },{ "sex": "male", "name ": "Sun" },{ "sex": "male", "name": "Zhao"}]};
Alert (data );
To do this? Print it out?