Parse JSON Array

Source: Internet
Author: User

VaR JSON = '[{"Sb-after-sales service-001": [{"Sb-after-sales service-0020.a3": "pipeline planning "}, {"Sb-after-sales service-0020.a4": "confirm basic training plan with customer"}] },{ "Sb-after-sales service-002 ": [{"Sb-after-sales service-002_e1": "received customer payment"}] ';
JSON = eval ('+ JSON + ')');
For (var I in JSON)
{
For (var key in JSON [I])
{
VaR json2 = JSON [I] [Key]; // job Array
Alert (key );
For (var k in json2)
{
For (var key in json2 [k])
{
Alert (Key + "," + json2 [k] [Key]);
}
}
}
}

//// // The second complex method is shown below

VaR STR = '{"consumable sales process": {"count": 1, "processset": [{"worktodoset": [{"ID ": "HC-sales process-0020.g4", "name": "Sales Contract Signing"}], "ID": "HC-sales process-001", "name ": "consumable sales process"}], "ID": "bcjumveeeq7", "name": "consumable sales process"}, "consumable customer complaint handling process ": {"count": 1, "processset": [{"worktodoset": [{"ID": "SB-HC-Customer Complaint Handling-00366g2", "name ": "Fill in customer complaint Complaint Form"}], "ID": "SB-HC-Customer Complaint Handling-001", "name": "equipment consumables customer complaint handling process"}], "ID": "bfa7ffcc12e554336631de8dfc4871", "name": "process for handling device consumables customer complaints"}, "device sales process": {"count": 0, "processset ": [], "ID": "fjmkr9t5nst", "name": "device sales process"}, "device after-sales service process": {"count": 3, "processset ": [{"worktodoset": [{"ID": "Sb-after-sales service-0020.a3", "name": "pipeline planning"}, {"ID ": "Sb-after-sales service-0020.a4", "name": "confirm basic training plan with customer"}], "ID": "Sb-after-sales service-001 ", "name": "after-sales service process of Equipment" },{ "worktodoset": [{"ID": "Sb-after-sales service-002_e1", "name ": "Received customer payment"}], "ID": "Sb-after-sales service-002", "name": "after-sales service process of Equipment"}], "ID ": "bfa7ffcc12f13b23b38fa7cf0bcb54", "name": "device after-sales service process"}, "device procurement and installation process": {"count": 2, "processset ": [{"worktodoset": [{"ID": "mk-20120307001_A2", "name": "Technical Standard available"}], "ID": "mk-20120307001", "name ": "device procurement and installation process" },{ "worktodoset": [{"ID": "mk-20120306002_A2", "name": "provide technical standards"}], "ID ": "mk-20120306002", "name": "equipment procurement and installation process"}], "ID": "bfa7ffcc12f142a7e3ddae8ed90c87", "name ": "device procurement and installation process "}}';
VaR JSON = eval ('+ STR + ')');
For (var I in JSON)
{
Document. write (JSON [I]. name + "[" + JSON [I]. ID + "]" + "(" + JSON [I]. count + ")");
Document. Write ("</BR> ");
}

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.