0

I have Json data ,product keys are dynamically changed, By using this product keys we are trying to bind this data to 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"
                    }
                }
            }
        ]
    }

I have Json data ,product keys are dynamically changed, By using this product keys we are trying to bind this data to html java script:

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

1 Answer 1

0

Try this

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]);
    }
}

Fiddle

Sign up to request clarification or add additional context in comments.

1 Comment

The values must mach and bind with product properties that is "ProductKeys": ["Machine Dimensions.Color"] match with "ProductProperties": {"Machine Dimensions": { "Weight": "1111111", "Dimension": "2222222", "Color": "3333333333" }, the result will be 3333333333

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.