Access an object by ID

Hi

I’m just jquery to access an object using:

obj["surveySpec"]["3"]["Survey"]["5"]["description"];

the problem is that depending on the results it can be a different length, what does stay the same is the id of 42333

Is there a way to search for that ID and bring back the values?

I tried var result2 = $.grep(obj2, function(e){ return e.id === 42333; }); but that didn’t work

The object is:


Object
	Object
	id:1
	registration:"NA123"
	serviceVersion:"V2"
surveySpec:Array[7]
0:Object
1:Object
2:Object
3:Object
	Survey:Array[15]
	0:Object
	1:Object
	2:Object
	3:Object
	4:Object
	5:Object
	description:"survey results, 5, 2 and 3"
	id:42333
	items:Array[3]
	name:"survey results"
	value:"standard"

Any help would be appreciated as i appear to be going round in circles.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.