In my Rails app I have built a JSON response for a page which I need to search through in my JavaScript.
A small part of my JSON looks like:
{
"album": {
"id": 117716,
"title": "title",
"description": "",
"flickr_id": "72157634990883894",
"collection_id": 3680,
"photos": [
{
"photo": {
"id": 564585,
"title": "IMG_18452",
"description": "",
"flickr_id": "944346935",
"flickr_secret": "74e34579046",
"flickr_server": "72418",
"flickr_farm": "7",
"flickr_original_secret": "efdfd1afb65",
"format": "jpg",
"width": 1536,
"height": 2048,
"source_small_square": "http://farm8.staticflickr.com/74e18/9434508316935_74e3fa7906_s.jpg",
"source_large_square": "http://farm8.staticflickr.com/774e18/940831456935_74e3fa7906_q.jpg",
"source_thumbnail": "http://farm8.staticflickr.com/741e8/9408316935_74e3fasfg7906_t.jpg",
"source_small_240": "http://farm8.staticflickr.com/74r18/940831693dfh5_74e3fa7906_m.jpg",
"source_small_320": "http://farm8.staticflickr.com/74t18/94083169fgh35_74e3fa7906_n.jpg",
"source_medium_640": "http://farm8.staticflickr.com/874e18/940t865316935_74e3fa7906_z.jpg",
"source_medium_800": "http://farm8.staticflickr.com/37418/94083165356935_74e3fa7906_c.jpg",
"source_large": "http://farm8.staticflickr.com/2746518/940831695635_74e3fa7906_b.jpg",
"source_original": "http://farm8.staticflickr.com/745618/9408346416935_efe51afb65_o.jpg"
}
},
{
"photo": {
<another photo>
}
}]
}}
Basically I have an integer in my JavaScript, like 564585
and need to search through this array somehow to find a photo with an id that matches. What is the best way of doing this?
I found this page and script: http://devcrapshoot.com/javascript/how-to-search-a-javascript-object-array
I gave it a test and it seems to locate things higher up in the object no problem but it cannot locate what I need. But if it did then that script would be perfect.
Any ideas?