I need to be able to identify certain attributes of a JSON response that is not always formatted the same way. A snippet of the example is:
{
"Attributes" : [
{
"Value" : "4 bedrooms",
"DisplayName" : "Bedrooms",
"Name" : "bedrooms"
},
{
"Value" : "2 bathrooms",
"DisplayName" : "Bathrooms",
"Name" : "bathrooms"
},
{
"Value" : "House",
"DisplayName" : "Property type",
"Name" : "property_type"
},
{
"Value" : "$780,000",
"DisplayName" : "Rateable value",
"Name" : "rateable_value"
},
{
"Value" : "Price by negotiation",
"DisplayName" : "Price",
"Name" : "price"
},
{
"Value" : "13 Wellswood Way\r\nLower Shotover\r\nQueenstown-Lakes\r\nOtago",
"DisplayName" : "Location",
"Name" : "location"
},
{
"Value" : "Queenstown-Lakes",
"DisplayName" : "District",
"Name" : "district"
},
{
"Value" : "Lower Shotover",
"DisplayName" : "Suburb",
"Name" : "suburb"
},
{
"Value" : "Otago",
"DisplayName" : "Region",
"Name" : "region"
},
{
"Value" : "254m²",
"DisplayName" : "Floor area",
"Name" : "floor_area"
},
{
"Value" : "1690m²",
"DisplayName" : "Land area",
"Name" : "land_area"
},
{
"Value" : "CBM959",
"DisplayName" : "Property ID#",
"Name" : "property_id"
},
{
"Value" : "playground,tennis,hiking,biking,historic bridge walk,buses,5 mins to shops.",
"DisplayName" : "In the area",
"Name" : "in_the_area"
},
{
"Value" : "Large double garage.Plenty off-street parking.Extra for boat+ etc.",
"DisplayName" : "Parking",
"Name" : "parking"
}
]
}
As you can see the Name, DisplayName and Value are repeated for each attribute. What I don’t know how to do is go through these attributes to find a particular one. For example, how would I get the value for Bathrooms?
Thanks for your help
Adam
Example –
Demo – http://jsfiddle.net/PktXh/