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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
...
var object = req.responseJSON.Obj,
array = Object.isArray(object) ? object : [object];
...
array.each( ... )
...
- kangax
On Jun 24, 2:20 pm, buda <buda...-2QRbNuDDdII@public.gmane.org>
wrote:> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Thankth kagnax And whence only you know all? :) On 24 июн, 23:26, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ... > var object = req.responseJSON.Obj, > array = Object.isArray(object) ? object : [object]; > ... > array.each( ... ) > ... > > - kangax > > On Jun 24, 2:20 pm, buda <buda...-2QRbNuDDdII@public.gmane.org> wrote: > > > > > 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- Скрыть цитируемый текст - > > - Показать цитируемый текст ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---