I work with JSON property like Obj which might be null, a single
oblect or a collection of objects
Every time I must analize
if (req.responseJSON.Obj == null){
....
}
if (req.responseJSON.Obj && !req.responseJSON.Obj.length){
... ia a single instanse
}
if (req.responseJSON.Obj && req.responseJSON.Obj.length){
req.responseJSON.Obj.each(....)
}
but I want to do with resul in the same manner
req.responseJSON.Obj.each(....)
if I use $A(req.responseJSON.Obj) it doesnt represent a single
instanse as an array and how should I do it ?
Help me please
on 2008-06-24 20:21
on 2008-06-24 22:27
...
var object = req.responseJSON.Obj,
array = Object.isArray(object) ? object : [object];
...
array.each( ... )
...
- kangax