Convert values from list form serialization to standard JSON

Source: Internet
Author: User

                    varJSON = {"Name": ["1111", "222"], "sex": ["Male", "female"], "age": ["1111", "2222"], "uNo": ["111", "2222"]};//The format taken from the list form
      varparam = [];//Defining Arrays for(vari = 0; I < json.name.length;i++) {//there is a bug in length here, and then change backname=Json.name[i]; Sex=Json.sex[i]; Age=Json.age[i]; UNo=Json.uno[i]; Param.push ({Name:name,sex:sex,age:age,uno:uno});//Append to array } vardata = json.stringify (param,NULL, 4); alert (data);

Format after the turn

[    {        "name": "1111",        "sex        ": "Male", "Age": "1111",        "UNo": "111 "    },    {        " name ":" 222 ",        " sex ":" female ",        " age ":" 2222 ",         "UNo": "2222"    }]

Stitching into the JSON that you want in the background

var data2 = "{" + ' "data" ' + ":" + data+ "}";
alert (DATA2);

Convert values from list form serialization to standard JSON

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.