Vielen Dank für das Lesen!Suche Schlüsselwertpaar in Multi-Dimension-Array
Ich habe ein JSON-Objekt, das ich suchen muss, um zu finden, ob ein Wert da ist. Das Problem, das ich habe, untersucht ein Array und dann innerhalb des Feature-Arrays, um zu testen, ob "In Ground Pool" existiert.
Vielen Dank!
targetListing ist mein JSON-Objekt
var targetFeature = "In Ground Pool";
function valuateFeature(targetFeature){
for(var i = 0, len = targetListing.Features.length; i < len; i++) {
if(targetListing.Features[i][0] === targetFeature) {
return true
}else{
return false
}
};
} ;
Address
:
Object
AgentEmail
:
"xxxxx"
AgentId
:
"xxxx"
AgentName
:
"Richard Getz"
AgentPhone
:
"xxxx"
AllListings
:
false
Bath
:
0
Bedroom
:
5
Brokerage
:
"xxxx"
BuildingStyle
:
"House"
BuildingStyleId
:
1
DaysPosted
:
0
Description
:
"If you've ever ..."
Features
:
Array[2]
0
:
Object
Description
:
"In Ground Pool"
__proto__
:
Object
1
:
Object
Description
:
"Attached Garage"
__proto__
:
Object
length
:
2
__proto__
:
Array[0]
HouseType
:
"Mediterranean"
HouseTypeId
:
3
Images
:
Array[0]
Es wäre besser, wenn Sie den JSON gepostet haben (verwenden Sie jsonlint.com, um ihn schön zu formatieren). Es ist unmöglich, die Struktur der Daten von Ihrer Frage zu unterscheiden. – Barmar