0

我有 Json 数据,产品密钥是动态更改的,通过使用此产品密钥,我们试图将此数据绑定到 html

json:

{
        "ProductIdProperties": [
            {
                "productId": "890e5b4ceb9842c9bd8d8a01094b1e5f",
                "ProductKeys": [
                    ".Not Covered in Warranty",
                    ".Warranty Summary",
                    "Machine Dimensions.Color",
                    "Machine Dimensions.Dimension",
                    "Machine Dimensions.Weight",
                    "Ports/Slots.Other Ports",
                    "Ports/Slots.Multi Card Slot",
                    "Ports/Slots.VGA Port",
                    "Ports/Slots.HDMI Port",
                    "Ports/Slots.RJ45 LAN",
                    "Ports/Slots.Mic In",
                    "Ports/Slots.USB Port",
                    "Power.Battery Cell",
                    "Power.Power Supply",
                    "Power.Battery Backup",
                    "Communication.Bluetooth",
                    "Communication.Wireless LAN",
                    "Communication.Ethernet",
                    "Audio.Sound",
                    "Audio.Speakers",
                    "Audio.Internal Mic",
                    "Input.Keyboard",
                    "Input.Pointer Device",
                    "Input.Web Camera",
                    "Graphics.Graphic Processor",
                    "Display.Screen Type",
                    "Display.Resolution",
                    "Display.Screen Size",
                    "Platform.System Architecture",
                    "Platform.Operating System",
                    "Optical Disk Drive.Optical Drive",
                    "Optical Disk Drive.Read/Write Speed",
                    "Storage.HDD Capacity",
                    "Storage.RPM",
                    "Storage.Hardware Interface",
                    "Memory.System Memory",
                    "Memory.Memory Slots",
                    "Memory.Expandable Memory",
                    "Processor.Cache",
                    "Processor.Clock Speed",
                    "Processor.Brand",
                    "Processor.Chipset",
                    "Processor.Variant",
                    "Processor.Processor",
                    "General1.Model ID",
                    "General1.Lifestyle",
                    "General1.Model Name",
                    "General1.Brand",
                    "In the Box.Sales Package"
                ],
                "imageUrls": [
                    "/images/Chrysanthemum.jpg"
                ],
                "ProductProperties": {
                    "Sales Package": [
                        "Laptop",
                        "User Guide and Manuals"
                    ],
                    "General1": {
                        "Brand": "ssssssssssssss",
                        "Model Name": "aaaaaaaaaaaaaaaaaa",
                        "Lifestyle": "aaaaaaaaaaaaaaaaaa",
                        "Model ID": "rrrrrrrrrrrrrrrrrrrrr"
                    },
                    "Processor": {
                        "Processor": "hjj",
                        "Variant": "khj",
                        "Chipset": "khjhj",
                        "Brand": "hjh",
                        "Clock Speed": "kj",
                        "Cache": "jh"
                    },
                    "Memory": {
                        "Expandable Memory": "jkh",
                        "Memory Slots": "hj",
                        "System Memory": "hj"
                    },
                    "Storage": {
                        "Hardware Interface": "h",
                        "RPM": "jh",
                        "HDD Capacity": "jh"
                    },
                    "Optical Disk Drive": {
                        "Read/Write Speed": "jh",
                        "Optical Drive": "jh"
                    },
                    "Platform": {
                        "Operating System": "jkhkj",
                        "System Architecture": "hkj"
                    },
                    "Display": {
                        "Screen Size": "hkj",
                        "Resolution": "hjh",
                        "Screen Type": "h"
                    },
                    "Graphic Processor": "kj",
                    "Input": {
                        "Web Camera": "kj",
                        "Pointer Device": "hkjh",
                        "Keyboard": "h"
                    },
                    "Audio": {
                        "Internal Mic": "hkj",
                        "Speakers": "hj",
                        "Sound": "hh"
                    },
                    "Communication": {
                        "Ethernet": "j",
                        "Wireless LAN": "hj",
                        "Bluetooth": "h"
                    },
                    "Power": {
                        "Battery Backup": "hh",
                        "Power Supply": "h",
                        "Battery Cell": "h"
                    },
                    "Ports/Slots": {
                        "USB Port": "hh",
                        "Mic In": "Yes",
                        "RJ45 LAN": "Yes",
                        "HDMI Port": "Yes",
                        "VGA Port": "Yes",
                        "Multi Card Slot": "mmmmmmmmmmm",
                        "Other Ports": [
                            "Headphone Jack ",
                            "Audio Jack"
                        ]
                    },
                    "Machine Dimensions": {
                        "Weight": "1111111",
                        "Dimension": "2222222",
                        "Color": "3333333333"
                    },
                    "": {
                        "Warranty Summary": "44444444444",
                        "Not Covered in Warranty": "5555555555555"
                    }
                }
            }
        ]
    }

我有 Json 数据,产品密钥是动态更改的,通过使用此产品密钥,我们试图将此数据绑定到 html java 脚本:

for (var prop in ProductProperties)
    {
    alert(prop);
    }    
4

1 回答 1

0

尝试这个

var arr={
    "ProductIdProperties": [
        {
            "productId": "890e5b4ceb9842c9bd8d8a01094b1e5f",
            "ProductKeys": [
                ".Not Covered in Warranty",
                ".Warranty Summary",
                "Machine Dimensions.Color",
                "Machine Dimensions.Dimension",
                "Machine Dimensions.Weight",
                "Ports/Slots.Other Ports",
                "Ports/Slots.Multi Card Slot",
                "Ports/Slots.VGA Port",
                "Ports/Slots.HDMI Port",
                "Ports/Slots.RJ45 LAN",
                "Ports/Slots.Mic In",
                "Ports/Slots.USB Port",
                "Power.Battery Cell",
                "Power.Power Supply",
                "Power.Battery Backup",
                "Communication.Bluetooth",
                "Communication.Wireless LAN",
                "Communication.Ethernet",
                "Audio.Sound",
                "Audio.Speakers",
                "Audio.Internal Mic",
                "Input.Keyboard",
                "Input.Pointer Device",
                "Input.Web Camera",
                "Graphics.Graphic Processor",
                "Display.Screen Type",
                "Display.Resolution",
                "Display.Screen Size",
                "Platform.System Architecture",
                "Platform.Operating System",
                "Optical Disk Drive.Optical Drive",
                "Optical Disk Drive.Read/Write Speed",
                "Storage.HDD Capacity",
                "Storage.RPM",
                "Storage.Hardware Interface",
                "Memory.System Memory",
                "Memory.Memory Slots",
                "Memory.Expandable Memory",
                "Processor.Cache",
                "Processor.Clock Speed",
                "Processor.Brand",
                "Processor.Chipset",
                "Processor.Variant",
                "Processor.Processor",
                "General1.Model ID",
                "General1.Lifestyle",
                "General1.Model Name",
                "General1.Brand",
                "In the Box.Sales Package"
            ],
            "imageUrls": [
                "/images/Chrysanthemum.jpg"
            ],
            "ProductProperties": {
                "Sales Package": [
                    "Laptop",
                    "User Guide and Manuals"
                ],
                "General1": {
                    "Brand": "ssssssssssssss",
                    "Model Name": "aaaaaaaaaaaaaaaaaa",
                    "Lifestyle": "aaaaaaaaaaaaaaaaaa",
                    "Model ID": "rrrrrrrrrrrrrrrrrrrrr"
                },
                "Processor": {
                    "Processor": "hjj",
                    "Variant": "khj",
                    "Chipset": "khjhj",
                    "Brand": "hjh",
                    "Clock Speed": "kj",
                    "Cache": "jh"
                },
                "Memory": {
                    "Expandable Memory": "jkh",
                    "Memory Slots": "hj",
                    "System Memory": "hj"
                },
                "Storage": {
                    "Hardware Interface": "h",
                    "RPM": "jh",
                    "HDD Capacity": "jh"
                },
                "Optical Disk Drive": {
                    "Read/Write Speed": "jh",
                    "Optical Drive": "jh"
                },
                "Platform": {
                    "Operating System": "jkhkj",
                    "System Architecture": "hkj"
                },
                "Display": {
                    "Screen Size": "hkj",
                    "Resolution": "hjh",
                    "Screen Type": "h"
                },
                "Graphic Processor": "kj",
                "Input": {
                    "Web Camera": "kj",
                    "Pointer Device": "hkjh",
                    "Keyboard": "h"
                },
                "Audio": {
                    "Internal Mic": "hkj",
                    "Speakers": "hj",
                    "Sound": "hh"
                },
                "Communication": {
                    "Ethernet": "j",
                    "Wireless LAN": "hj",
                    "Bluetooth": "h"
                },
                "Power": {
                    "Battery Backup": "hh",
                    "Power Supply": "h",
                    "Battery Cell": "h"
                },
                "Ports/Slots": {
                    "USB Port": "hh",
                    "Mic In": "Yes",
                    "RJ45 LAN": "Yes",
                    "HDMI Port": "Yes",
                    "VGA Port": "Yes",
                    "Multi Card Slot": "mmmmmmmmmmm",
                    "Other Ports": [
                        "Headphone Jack ",
                        "Audio Jack"
                    ]
                },
                "Machine Dimensions": {
                    "Weight": "1111111",
                    "Dimension": "2222222",
                    "Color": "3333333333"
                },
                "": {
                    "Warranty Summary": "44444444444",
                    "Not Covered in Warranty": "5555555555555"
                }
            }
        }
    ]
}
var k=arr.ProductIdProperties
for(var i in k)
{
 var ke=(k[i].ProductKeys );  
    for(var j in ke)
    {
        console.log(ke[j]);
    }
}

小提琴

于 2013-11-12T11:33:44.177 回答