I want to loop though all values under services_raw_nl
and get the name and number belonging to thoses values, e.g.
In-house Catering and 9
and
Live music and 6
I want to use a for-in loop, but I have 2 problems:
- the problem is that the name of
services_raw_nl
may also beservices_raw_en
(depending on the chosen language of the user). - I'm unsure how to access the properties and their values. Basically I just want to get the name and value of a property under
services_raw_nl
by their index.
I wanted to make this available as a JSFiddle, but don't know how to make the JSON data available there and since this service is not yet live I can not call it from JSFiddle.
{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"facet":"true",
"sort":"membervalue desc",
"fl":"id,city,thumb",
"facet.mincount":"1",
"indent":"on",
"start":"0",
"q":["*:*",
"*:*"],
"facet.field":["country_raw_nl",
"services_raw_nl",
"city"],
"wt":"json",
"fq":"country_nl:=australie",
"rows":"12"}},
"response":{"numFound":10,"start":0,"docs":[
{
"id":"842",
"city":"whitsundays",
"thumb":"735_739_CEREMONY-PAVILLION-2.jpg"}]
},
"facet_counts":{
"facet_queries":{},
"facet_fields":{
"country_raw_nl":[
"Australie",10],
"services_raw_nl":[
"In-house Catering",9,
"Live music",6],
"partylocation":[
"true",8,
"false",2],
"hasphoto":[
"true",9,
"false",1],
"hasvideo":[
"false",10],
"rating":[
"0.0",10],
"rating_rounded":[
"0.0",10],
"facet_dates":{},
"facet_ranges":{}}}
Here's the loop I'm trying:
for (var service in response.facet_counts.facet_fields.services_raw_nl) {
console.log(response.facet_counts.facet_fields.services_raw_nl[service].???);
}