SPListItem is spliced into Json format, and splistitem is spliced into json format

Source: Internet
Author: User

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?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.