[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to check if there are more than one attributes for a value in returned json and populate a select list if so

Posted on 2013-12-27
8
Medium Priority
?
391 Views
Last Modified: 2013-12-27
Hi,
Below is an example of some json that is returned to me via curl. Occasionally there are more than one attribute for 'style' shown below (near the bottom). This is to indicate there is more than one potential vehicle that matches the vin and I need to choose one of them using the style['@attributes'].id and send back to the webservice to narrow it down properly.

I'm trying to figure out:
1) how to check if there are more than one attribute sent for the style when the json is returned?
2) then if so, need to populate a selectlist with the style.id as the value and the styleName for the choice.

If I can populate a selectlist when there is more than one, I can figure out how to send via ajax back to the webservice. Just don't know how to get the result into a select.

I'm thinking some kind of foreach loop? Not sure how to put it together and its very slow to keep trying 'ideas', so hoping someone can take away a bunch of the guessing.


{ "@attributes" : { "bestMakeName" : "Volvo",
      "bestModelName" : "S40",
      "bestStyleName" : "4dr Sdn 2.4L FWD",
      "country" : "CA",
      "language" : "en",
      "modelYear" : "2010"
    },
  "basePrice" : { "@attributes" : { "unknown" : "false" },
      "destination" : { "@attributes" : { "high" : "1095.0",
              "low" : "1095.0"
            } },
      "invoice" : { "@attributes" : { "high" : "39060.0",
              "low" : "26970.0"
            } },
      "msrp" : { "@attributes" : { "high" : "41995.0",
              "low" : "28995.0"
            } }
    },
  "engine" : { "@attributes" : { "highOutput" : "false" },
      "cylinders" : "5",
      "displacement" : { "@attributes" : { "liters" : "2.4" } },
      "engineType" : "5 Cylinder Engine",
      "fuelCapacity" : { "@attributes" : { "high" : "60.0",
              "low" : "60.0",
              "unit" : "L"
            } },
      "fuelEconomy" : { "@attributes" : { "unit" : "L/100 km" },
          "city" : { "@attributes" : { "high" : "10.6",
                  "low" : "10.3"
                } },
          "hwy" : { "@attributes" : { "high" : "7.1",
                  "low" : "7.0"
                } }
        },
      "fuelType" : "Gasoline Fuel",
      "horsepower" : { "@attributes" : { "rpm" : "6000",
              "value" : "168.0"
            } },
      "installed" : { "@attributes" : { "cause" : "VIN" } },
      "netTorque" : { "@attributes" : { "rpm" : "4400",
              "value" : "170.0"
            } }
    },
  "genericEquipment" : [ { "categoryId" : "1001",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1002",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1005",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1007",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1008",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1011",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1014",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1017",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1018",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1020",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1033",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1034",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1039",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1042",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1049",
        "installed" : { "@attributes" : { "cause" : "Engine" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1055",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1059",
        "installed" : { "@attributes" : { "cause" : "Engine" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1062",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1063",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1064",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1065",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1076",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1077",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1082",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1084",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1087",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1092",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1097",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1100",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1126",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1127",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1150",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1159",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1164",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1166",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1174",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1187",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1188",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1227",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1228",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1230",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1299",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1304",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "categoryId" : "1310",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      }
    ],
  "responseStatus" : { "@attributes" : { "description" : "Successful",
          "responseCode" : "Successful"
        } },
  "standard" : [ { "category" : [ { "@attributes" : { "id" : "1049" } },
            { "@attributes" : { "id" : "1059" } }
          ],
        "description" : "2.4L DOHC 20-valve aluminum I5 engine",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "Engine" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Continuously variable valve timing",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1042" } },
        "description" : "Front wheel drive",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Comfort chassis",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "MacPherson strut front suspension",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Multi-link rear suspension w/coil springs",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Front/rear stabilizer bars",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1084" } },
        "description" : "Speed-sensitive pwr rack & pinion steering",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1020" } },
        "description" : "4-wheel pwr disc brakes (front ventilated)",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Colour coordinated door mouldings",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Colour coordinated lower body waist mouldings",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Side marker lights",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Home safe lighting",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Approach lighting",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Home Safe lights",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Tinted windows",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : [ { "@attributes" : { "id" : "1076" } },
            { "@attributes" : { "id" : "1304" } }
          ],
        "description" : "Foldable 60/40 split rear seat w/(3) head restraints (centre-rear is adjustable)",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Front/rear armrests & headrests",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Front door storage",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Front seat back storage pockets",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Centre console w/roll top",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Front/rear cupholders",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1166" } },
        "description" : "Immobilizer",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Outside temp display",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1126" } },
        "description" : "Pwr windows w/auto up/down",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1033" } },
        "description" : "Cruise control",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1034" } },
        "description" : "Rear-window defroster w/auto timer",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Illuminated locking glove box",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1164" } },
        "description" : "12V outlet",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : [ { "@attributes" : { "id" : "1187" } },
            { "@attributes" : { "id" : "1188" } }
          ],
        "description" : "Front/rear reading lights",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Interior cabin light delay",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1018" } },
        "description" : "Anti-lock braking system",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Electronic brake distribution",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1228" } },
        "description" : "Emergency brake assistance",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : [ { "@attributes" : { "id" : "1100" } },
            { "@attributes" : { "id" : "1227" } }
          ],
        "description" : "Dynamic stability & traction control system",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Pedestrian protection",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1005" } },
        "description" : "Side-impact protection system airbags (SIPS)-inc: front seat mounted side airbags",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : [ { "@attributes" : { "id" : "1007" } },
            { "@attributes" : { "id" : "1008" } }
          ],
        "description" : "Inflatable side curtain airbags",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "(5) 3-point seat belts w/outboard pretensioners/front force-limiters",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Whiplash protection system front seats",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "ISO-FIX rear seat",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "description" : "Collapsible steering column",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1039" } },
        "description" : "Rear door mechanical child locks",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "316423",
            "316424",
            "316425",
            "316426",
            "316427",
            "316428"
          ]
      }
    ],
  "style" : [ { "@attributes" : { "altBodyType" : "4dr Car",
            "drivetrain" : "Front Wheel Drive",
            "fleetOnly" : "false",
            "id" : "316423",
            "mfrModelCode" : "S40",
            "modelFleet" : "false",
            "modelYear" : "2010",
            "name" : "4dr Sdn 2.4L Man FWD",
            "nameWoTrim" : "4dr Sdn 2.4L Man FWD",
            "passDoors" : "4"
          },
        "basePrice" : { "@attributes" : { "destination" : "1095.0",
                "invoice" : "26970.0",
                "msrp" : "28995.0",
                "unknown" : "false"
              } },
        "bodyType" : "4dr Car",
        "division" : "Volvo",
        "marketClass" : "4-door Compact Passenger Car",
        "model" : "S40",
        "stockImage" : { "@attributes" : { "filename" : "12304.jpg",
                "height" : "200",
                "url" : "http://media.carbook.com/autoBuilderData/stockPhotos/12304.jpg",
                "width" : "400"
              } },
        "subdivision" : "Volvo"
      },
      { "@attributes" : { "altBodyType" : "4dr Car",
            "drivetrain" : "Front Wheel Drive",
            "fleetOnly" : "false",
            "id" : "316424",
            "mfrModelCode" : "S40",
            "modelFleet" : "false",
            "modelYear" : "2010",
            "name" : "4dr Sdn 2.4L Auto FWD",
            "nameWoTrim" : "4dr Sdn 2.4L Auto FWD",
            "passDoors" : "4"
          },
        "basePrice" : { "@attributes" : { "destination" : "1095.0",
                "invoice" : "28365.0",
                "msrp" : "30495.0",
                "unknown" : "false"
              } },
        "bodyType" : "4dr Car",
        "division" : "Volvo",
        "marketClass" : "4-door Compact Passenger Car",
        "model" : "S40",
        "stockImage" : { "@attributes" : { "filename" : "12304.jpg",
                "height" : "200",
                "url" : "http://media.carbook.com/autoBuilderData/stockPhotos/12304.jpg",
                "width" : "400"
              } },
        "subdivision" : "Volvo"
      },
      { "@attributes" : { "altBodyType" : "4dr Car",
            "drivetrain" : "Front Wheel Drive",
            "fleetOnly" : "false",
            "id" : "316425",
            "mfrModelCode" : "S40",
            "modelFleet" : "false",
            "modelYear" : "2010",
            "name" : "4dr Sdn 2.4L Man FWD Premium",
            "nameWoTrim" : "4dr Sdn 2.4L Man FWD",
            "passDoors" : "4",
            "trim" : "Premium"
          },
        "basePrice" : { "@attributes" : { "destination" : "1095.0",
                "invoice" : "33480.0",
                "msrp" : "35995.0",
                "unknown" : "false"
              } },
        "bodyType" : "4dr Car",
        "division" : "Volvo",
        "marketClass" : "4-door Compact Passenger Car",
        "model" : "S40",
        "stockImage" : { "@attributes" : { "filename" : "12304.jpg",
                "height" : "200",
                "url" : "http://media.carbook.com/autoBuilderData/stockPhotos/12304.jpg",
                "width" : "400"
              } },
        "subdivision" : "Volvo"
      },
      { "@attributes" : { "altBodyType" : "4dr Car",
            "drivetrain" : "Front Wheel Drive",
            "fleetOnly" : "false",
            "id" : "316426",
            "mfrModelCode" : "S40",
            "modelFleet" : "false",
            "modelYear" : "2010",
            "name" : "4dr Sdn 2.4L Auto FWD Premium",
            "nameWoTrim" : "4dr Sdn 2.4L Auto FWD",
            "passDoors" : "4",
            "trim" : "Premium"
          },
        "basePrice" : { "@attributes" : { "destination" : "1095.0",
                "invoice" : "34875.0",
                "msrp" : "37495.0",
                "unknown" : "false"
              } },
        "bodyType" : "4dr Car",
        "division" : "Volvo",
        "marketClass" : "4-door Compact Passenger Car",
        "model" : "S40",
        "stockImage" : { "@attributes" : { "filename" : "12304.jpg",
                "height" : "200",
                "url" : "http://media.carbook.com/autoBuilderData/stockPhotos/12304.jpg",
                "width" : "400"
              } },
        "subdivision" : "Volvo"
      },
      { "@attributes" : { "altBodyType" : "4dr Car",
            "drivetrain" : "Front Wheel Drive",
            "fleetOnly" : "false",
            "id" : "316427",
            "mfrModelCode" : "S40",
            "modelFleet" : "false",
            "modelYear" : "2010",
            "name" : "4dr Sdn 2.4L Man FWD R-Design",
            "nameWoTrim" : "4dr Sdn 2.4L Man FWD",
            "passDoors" : "4",
            "trim" : "R-Design"
          },
        "basePrice" : { "@attributes" : { "destination" : "1095.0",
                "invoice" : "37665.0",
                "msrp" : "40495.0",
                "unknown" : "false"
              } },
        "bodyType" : "4dr Car",
        "division" : "Volvo",
        "marketClass" : "4-door Compact Passenger Car",
        "model" : "S40",
        "stockImage" : { "@attributes" : { "filename" : "12304.jpg",
                "height" : "200",
                "url" : "http://media.carbook.com/autoBuilderData/stockPhotos/12304.jpg",
                "width" : "400"
              } },
        "subdivision" : "Volvo"
      },
      { "@attributes" : { "altBodyType" : "4dr Car",
            "drivetrain" : "Front Wheel Drive",
            "fleetOnly" : "false",
            "id" : "316428",
            "mfrModelCode" : "S40",
            "modelFleet" : "false",
            "modelYear" : "2010",
            "name" : "4dr Sdn 2.4L Auto FWD R-Design",
            "nameWoTrim" : "4dr Sdn 2.4L Auto FWD",
            "passDoors" : "4",
            "trim" : "R-Design"
          },
        "basePrice" : { "@attributes" : { "destination" : "1095.0",
                "invoice" : "39060.0",
                "msrp" : "41995.0",
                "unknown" : "false"
              } },
        "bodyType" : "4dr Car",
        "division" : "Volvo",
        "marketClass" : "4-door Compact Passenger Car",
        "model" : "S40",
        "stockImage" : { "@attributes" : { "filename" : "12304.jpg",
                "height" : "200",
                "url" : "http://media.carbook.com/autoBuilderData/stockPhotos/12304.jpg",
                "width" : "400"
              } },
        "subdivision" : "Volvo"
      }
    ],
  "technicalSpecification" : [ { "titleId" : "10",
        "value" : { "@attributes" : { "condition" : "",
                "value" : "- TBD -"
              },
            "styleId" : [ "316423",
                "316424",
                "316425",
                "316426",
                "316427",
                "316428"
              ]
          }
      },
      { "range" : { "@attributes" : { "max" : "176.2",
                "min" : "176.2"
              } },
        "titleId" : "304",
        "value" : { "@attributes" : { "condition" : "",
                "value" : "176.2"
              },
            "styleId" : [ "316423",
                "316424",
                "316425",
                "316426",
                "316427",
                "316428"
              ]
          }
      },
      { "range" : { "@attributes" : { "max" : "69.7",
                "min" : "69.7"
              } },
        "titleId" : "305",
        "value" : { "@attributes" : { "condition" : "",
                "value" : "69.7"
              },
            "styleId" : [ "316423",
                "316424",
                "316425",
                "316426",
                "316427",
                "316428"
              ]
          }
      },
      { "range" : { "@attributes" : { "max" : "57.2",
                "min" : "57.2"
              } },
        "titleId" : "306",
        "value" : { "@attributes" : { "condition" : "",
                "value" : "57.2"
              },
            "styleId" : [ "316423",
                "316424",
                "316425",
                "316426",
                "316427",
                "316428"
              ]
          }
      }
    ],
  "vinDescription" : { "@attributes" : { "bodyType" : "Sedan 4 Dr.",
          "division" : "Volvo",
          "drivingWheels" : "Front",
          "modelName" : "S40",
          "modelYear" : "2010",
          "styleName" : "4dr Sdn 2.4L FWD",
          "vin" : "YV1382MS6A2505148"
        },
      "WorldManufacturerIdentifier" : "Sweden Passenger Cars ",
      "marketClass" : "4-door Compact Passenger Car"
    }
}

Open in new window

0
Comment
Question by:tjyoung
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39742293
Using a foreach() iterator seems like a good approach.  I'll see if I can come up with a code sample for you.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39742323
Test page : http://jsfiddle.net/FY8P8/
$(document).ready(function() {
    if(data.style&&data.style.length) {
        var styles = data.style;
        var options = [];
        for(var i=0;i<styles.length;i++)
        {
            var style = styles[i]["@attributes"];
            options.push("<option value='" + style.id + "'>" + style.name + "</option>");
        }
        $("#styles").append( options.join() );
    }
});

Open in new window

0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39742336
Here is one of the "style" elements.  Can you please tell me what parts of this you want to extract?
object(stdClass)#336 (8) {
  ["@attributes"]=>
  object(stdClass)#337 (10) {
    ["altBodyType"]=>
    string(7) "4dr Car"
    ["drivetrain"]=>
    string(17) "Front Wheel Drive"
    ["fleetOnly"]=>
    string(5) "false"
    ["id"]=>
    string(6) "316423"
    ["mfrModelCode"]=>
    string(3) "S40"
    ["modelFleet"]=>
    string(5) "false"
    ["modelYear"]=>
    string(4) "2010"
    ["name"]=>
    string(20) "4dr Sdn 2.4L Man FWD"
    ["nameWoTrim"]=>
    string(20) "4dr Sdn 2.4L Man FWD"
    ["passDoors"]=>
    string(1) "4"
  }
  ["basePrice"]=>
  object(stdClass)#338 (1) {
    ["@attributes"]=>
    object(stdClass)#339 (4) {
      ["destination"]=>
      string(6) "1095.0"
      ["invoice"]=>
      string(7) "26970.0"
      ["msrp"]=>
      string(7) "28995.0"
      ["unknown"]=>
      string(5) "false"
    }
  }
  ["bodyType"]=>
  string(7) "4dr Car"
  ["division"]=>
  string(5) "Volvo"
  ["marketClass"]=>
  string(28) "4-door Compact Passenger Car"
  ["model"]=>
  string(3) "S40"
  ["stockImage"]=>
  object(stdClass)#340 (1) {
    ["@attributes"]=>
    object(stdClass)#341 (4) {
      ["filename"]=>
      string(9) "12304.jpg"
      ["height"]=>
      string(3) "200"
      ["url"]=>
      string(62) "http://media.carbook.com/autoBuilderData/stockPhotos/12304.jpg"
      ["width"]=>
      string(3) "400"
    }
  }
  ["subdivision"]=>
  string(5) "Volvo"
}

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:tjyoung
ID: 39742348
I'm looking for name and id. It looks as though @leakim971 posted a solution that is working. Was essentially trying to get the id and name to populate a selectlist.
Thanks very much for taking the time to look. Hope you had a great xmas.
0
 
LVL 1

Author Closing Comment

by:tjyoung
ID: 39742351
snapped right in, no issues. Thank you for taking the time!
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39742458
OK, sorry - when I saw this was in the PHP Zone, I thought you wanted a PHP solution.
0
 
LVL 1

Author Comment

by:tjyoung
ID: 39742464
Sorry my mistake. I was using curl/php so without thinking, posted along with php.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39742521
No prob -- Happy New Year to all, ~Ray
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question