Solved

Getting @attribute in my returned json and can't figure out how to access values

Posted on 2013-12-27
3
333 Views
Last Modified: 2013-12-27
HI,
I'm using curl to access a webservice for vin decoding vehicles. I'm getting a response but it has a few twists I haven't come across and having difficulty accessing the values.

the response looks like this: (its huge but didn't want to miss something that may be important).

{ "@attributes" : { "bestMakeName" : "Mazda",
      "bestModelName" : "Mazda3",
      "bestStyleName" : "4dr Sdn GX",
      "bestTrimName" : "GX",
      "country" : "CA",
      "language" : "en",
      "modelYear" : "2012"
    },
  "basePrice" : { "@attributes" : { "unknown" : "false" },
      "destination" : { "@attributes" : { "high" : "1695.0",
              "low" : "1695.0"
            } },
      "invoice" : { "@attributes" : { "high" : "0.0",
              "low" : "0.0"
            } },
      "msrp" : { "@attributes" : { "high" : "17095.0",
              "low" : "15895.0"
            } }
    },
  "engine" : { "@attributes" : { "highOutput" : "false" },
      "cylinders" : "4",
      "displacement" : { "@attributes" : { "cubicIn" : "122",
              "liters" : "2.0"
            } },
      "engineType" : "4 Cylinder Engine",
      "fuelCapacity" : { "@attributes" : { "high" : "55.0",
              "low" : "55.0",
              "unit" : "L"
            } },
      "fuelEconomy" : { "@attributes" : { "unit" : "L/100 km" },
          "city" : { "@attributes" : { "high" : "8.7",
                  "low" : "8.1"
                } },
          "hwy" : { "@attributes" : { "high" : "6.0",
                  "low" : "5.9"
                } }
        },
      "fuelType" : "Gasoline Fuel",
      "horsepower" : { "@attributes" : { "rpm" : "6500",
              "value" : "148.0"
            } },
      "installed" : { "@attributes" : { "cause" : "VIN" } },
      "netTorque" : { "@attributes" : { "rpm" : "4500",
              "value" : "135.0"
            } }
    },
  "genericEquipment" : [ { "categoryId" : "1001",
        "installed" : { "@attributes" : { "cause" : "VIN" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1002",
        "installed" : { "@attributes" : { "cause" : "VIN" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1005",
        "installed" : { "@attributes" : { "cause" : "VIN" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1007",
        "installed" : { "@attributes" : { "cause" : "VIN" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1008",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1014",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1017",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1018",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1020",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1034",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1039",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1042",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1048",
        "installed" : { "@attributes" : { "cause" : "Engine" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1055",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1059",
        "installed" : { "@attributes" : { "cause" : "Engine" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1062",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1063",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1065",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1076",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1077",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1082",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1084",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1087",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1092",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1097",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1098",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1100",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1126",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1127",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1150",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1159",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1164",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1166",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1175",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1176",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1187",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1197",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1198",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1227",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1230",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1304",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "categoryId" : "1310",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      }
    ],
  "responseStatus" : { "@attributes" : { "description" : "Successful",
          "responseCode" : "Successful"
        } },
  "standard" : [ { "category" : [ { "@attributes" : { "id" : "1048" } },
            { "@attributes" : { "id" : "1059" } }
          ],
        "description" : "2.0L DOHC 16-valve I4 engine",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "Engine" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1042" } },
        "description" : "Front wheel drive",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Front independent strut suspension w/coil springs",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Rear independent multi-link suspension w/coil springs",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Front/rear stabilizer bars",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1084" } },
        "description" : "Pwr rack & pinion steering",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1020" } },
        "description" : "Front ventilated/rear solid pwr disc brakes",
        "header" : "MECHANICAL",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : [ { "@attributes" : { "id" : "1092" } },
            { "@attributes" : { "id" : "1097" } }
          ],
        "description" : "P205/55R16 all-season tires",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1098" } },
        "description" : "Temporary spare tire",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Black grille w/black grille bar",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Halogen headlamps",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1065" } },
        "description" : "Body-colour pwr mirrors",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : [ { "@attributes" : { "id" : "1127" } },
            { "@attributes" : { "id" : "1159" } }
          ],
        "description" : "Variable intermittent windshield wipers",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Body-colour door handles",
        "header" : "EXTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : [ { "@attributes" : { "id" : "1014" } },
            { "@attributes" : { "id" : "1017" } },
            { "@attributes" : { "id" : "1150" } }
          ],
        "description" : "AM/FM stereo w/CD/MP3 player -inc: (4) speakers",
        "header" : "ENTERTAINMENT",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1230" } },
        "description" : "Aux input jack",
        "header" : "ENTERTAINMENT",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1082" } },
        "description" : "Front bucket seats w/active headrests",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : [ { "@attributes" : { "id" : "1076" } },
            { "@attributes" : { "id" : "1304" } }
          ],
        "description" : "60/40 split-folding rear seats w/adjustable headrests -inc: lock function",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Centre console w/lid",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Rear centre armrest w/(2) cupholders",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1055" } },
        "description" : "Custom fitted front/rear floor mats",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Driver foot rest",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1087" } },
        "description" : "Tilt/telescopic steering wheel",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Warning lights -inc: oil pressure, check engine, low washer fluid, low fuel level, door ajar, air bags",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Exterior temperature gauge",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1126" } },
        "description" : "Pwr windows w/driver 1-touch down feature & driver side illuminated switch",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1166" } },
        "description" : "Engine immobilizer theft deterrent system",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Rear heater ducts",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1034" } },
        "description" : "Rear window defroster",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Illuminated glove compartment",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Dual front cupholders",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1164" } },
        "description" : "(2) 12V pwr outlets",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Moulded cloth door trim",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Illuminated entry",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Front door storage pockets w/bottle holders",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Rear door bottle holders",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Day/night rearview mirror",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : [ { "@attributes" : { "id" : "1175" } },
            { "@attributes" : { "id" : "1176" } }
          ],
        "description" : "Driver/passenger sunvisors w/vanity mirrors",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "(3) passenger assist handles",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1187" } },
        "description" : "Map lights",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Trunk/cargo light",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Ignition key illumination",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Passenger side seatback pocket",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "(2) coat hooks",
        "header" : "INTERIOR",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1018" } },
        "description" : "Anti-lock brake system -inc: electronic brake-force distribution",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Side-impact door beams",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : [ { "@attributes" : { "id" : "1001" } },
            { "@attributes" : { "id" : "1002" } },
            { "@attributes" : { "id" : "1310" } }
          ],
        "description" : "Driver & front passenger air bags w/passenger sensor",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1005" } },
        "description" : "Front side-impact air bags",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : [ { "@attributes" : { "id" : "1007" } },
            { "@attributes" : { "id" : "1008" } }
          ],
        "description" : "Front/rear side curtain air bags",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Height-adjustable front seat belts w/pretensioners, force limiters",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "All seating position 3-point seat belts",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1197" } },
        "description" : "Internal trunk release",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "category" : { "@attributes" : { "id" : "1039" } },
        "description" : "Child safety rear door locks",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      },
      { "description" : "Integrated child seat anchor brackets",
        "header" : "SAFETY",
        "installed" : { "@attributes" : { "cause" : "BaseEquipment" } },
        "styleId" : [ "337292",
            "337293"
          ]
      }
    ],
  "style" : [ { "@attributes" : { "altBodyType" : "4dr Car",
            "drivetrain" : "Front Wheel Drive",
            "fleetOnly" : "false",
            "id" : "337292",
            "mfrModelCode" : "D4XS52",
            "modelFleet" : "false",
            "modelYear" : "2012",
            "name" : "4dr Sdn Man GX",
            "nameWoTrim" : "4dr Sdn Man",
            "passDoors" : "4",
            "trim" : "GX"
          },
        "basePrice" : { "@attributes" : { "destination" : "1695.0",
                "invoice" : "0.0",
                "msrp" : "15895.0",
                "unknown" : "false"
              } },
        "bodyType" : "4dr Car",
        "division" : "Mazda",
        "marketClass" : "4-door Compact Passenger Car",
        "model" : "Mazda3",
        "stockImage" : { "@attributes" : { "filename" : "14383.jpg",
                "height" : "200",
                "url" : "http://media.carbook.com/autoBuilderData/stockPhotos/14383.jpg",
                "width" : "400"
              } },
        "subdivision" : "Mazda Cars"
      },
      { "@attributes" : { "altBodyType" : "4dr Car",
            "drivetrain" : "Front Wheel Drive",
            "fleetOnly" : "false",
            "id" : "337293",
            "mfrModelCode" : "D4XS82",
            "modelFleet" : "false",
            "modelYear" : "2012",
            "name" : "4dr Sdn Auto GX",
            "nameWoTrim" : "4dr Sdn Auto",
            "passDoors" : "4",
            "trim" : "GX"
          },
        "basePrice" : { "@attributes" : { "destination" : "1695.0",
                "invoice" : "0.0",
                "msrp" : "17095.0",
                "unknown" : "false"
              } },
        "bodyType" : "4dr Car",
        "division" : "Mazda",
        "marketClass" : "4-door Compact Passenger Car",
        "model" : "Mazda3",
        "stockImage" : { "@attributes" : { "filename" : "14383.jpg",
                "height" : "200",
                "url" : "http://media.carbook.com/autoBuilderData/stockPhotos/14383.jpg",
                "width" : "400"
              } },
        "subdivision" : "Mazda Cars"
      }
    ],
  "technicalSpecification" : [ { "range" : { "@attributes" : { "max" : "2937.0",
                "min" : "2875.0"
              } },
        "titleId" : "10",
        "value" : [ { "@attributes" : { "condition" : "",
                  "value" : "2875"
                },
              "styleId" : "337292"
            },
            { "@attributes" : { "condition" : "",
                  "value" : "2937"
                },
              "styleId" : "337293"
            }
          ]
      },
      { "range" : { "@attributes" : { "max" : "180.9",
                "min" : "180.9"
              } },
        "titleId" : "304",
        "value" : { "@attributes" : { "condition" : "",
                "value" : "180.9"
              },
            "styleId" : [ "337292",
                "337293"
              ]
          }
      },
      { "range" : { "@attributes" : { "max" : "69.1",
                "min" : "69.1"
              } },
        "titleId" : "305",
        "value" : { "@attributes" : { "condition" : "",
                "value" : "69.1"
              },
            "styleId" : [ "337292",
                "337293"
              ]
          }
      },
      { "range" : { "@attributes" : { "max" : "57.9",
                "min" : "57.9"
              } },
        "titleId" : "306",
        "value" : { "@attributes" : { "condition" : "",
                "value" : "57.9"
              },
            "styleId" : [ "337292",
                "337293"
              ]
          }
      }
    ],
  "vinDescription" : { "@attributes" : { "bodyType" : "Sedan",
          "division" : "Mazda",
          "drivingWheels" : "Front",
          "modelName" : "Mazda3",
          "modelYear" : "2012",
          "styleName" : "4dr Sdn GX",
          "vin" : "JM1BL1UF3C1627780"
        },
      "WorldManufacturerIdentifier" : "Japan Mazda Passenger Car ",
      "marketClass" : "4-door Compact Passenger Car",
      "restraintTypes" : [ { "category" : "Driver Air Bag",
            "group" : "Safety",
            "header" : "Air Bag - Frontal"
          },
          { "category" : "Passenger Air Bag",
            "group" : "Safety",
            "header" : "Air Bag - Frontal"
          },
          { "category" : "Front Side Air Bag",
            "group" : "Safety",
            "header" : "Air Bag - Side"
          },
          { "category" : "Front Head Air Bag",
            "group" : "Safety",
            "header" : "Air Bag - Side"
          }
        ]
    }
}

Open in new window

I'm trying to access the values for vinDescription (modelYear, modelName as an example).

With those values I'm populating a few input fields using jquery. That works fine if I had the correct way of referencing the values. I'm using for partial example:

function(data){
      $('input[name="year"]').val(data.vinDescription.modelYear);
      },
    'json');

the data.vinDescription.modelYear isn't getting the correct value/failing.

Here is a portion of the curl request that is getting the above response if that helps at all:

$vehicle = simplexml_load_string($result);
                    // Output result
            header('Cache-Control: no-cache, must-revalidate');
            header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
            header('Content-type: application/json');
            echo json_encode($vehicle);
0
Comment
Question by:tjyoung
  • 2
3 Comments
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 500 total points
ID: 39741955
Try data.vinDescription['@attributes'].modelYear
0
 
LVL 1

Author Closing Comment

by:tjyoung
ID: 39741975
awesome thanks. I tried a multitude of ways but couldn't figure out how to handle the attribute.
0
 
LVL 1

Author Comment

by:tjyoung
ID: 39742051
Sorry, must have been cached. Seems to be working now.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

895 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now