retrieve a complex JSON response and display the parts that I want from it
this is the first time I use JSON and underscore.js.
I'm getting a JSON response :
response Object { numFound=12, start=0, docs=[10]} responseHeader Object {
status=0, QTime=1, params={...}}
the docs nested array has another nested array like this
0 { id="23", name="8asjkdnsd",absolute_path="kkskskmasd8234", more... } .
. . 9 { id="89234", name="awdcs",absolute_path="qwdacsc", more... }
I want to use underscore.js in my jquery script to convert the response to
an array to be able to access any key, value pair when I want to, like if
I want to print all the names inside the docs[10]?
I'm trying something like this :
_.each(response.docs.name, function(docs){console.log(response.name);});
but I'm getting undefined and actually I don't know what I'm doing. so any
help would be appreciated.
thanks in advance.
No comments:
Post a Comment