i´m sorry, i think i have made a mistake, this is not the proper group
to ask for that...
I will do it in Prototype and Scriptaculous group...

Best regards.


On May 29, 9:52 am, dgalvez <danielgalvezvalenzu...@gmail.com> wrote:
>       the point is, sometimes i receive a json object like
>
>       var json = {
>           element: ['1','2','3']
>       }
>
>       and sometimes element has just one element so it is presented as
> a String not an Array:
>
>       var json = {
>           element: '1'
>       }
>
>       And i want to iterate over json.element independently of its
> type, i normally do something like:
>
>       objectToArray(json.element).each(function(ele){ ... }.bind
> (this));
>
>       where objectToArray is something like this:
>
>       function objectToArray(obj) {
>             if (!Object.isArray(obj) && !Object.isHash(obj)) {
>                    var objArray = [obj];
>                    return objArray;
>             }
>             return obj;
>        }
>
>        So my question is, it is possible doing that by adding the each
> () method to the Object class,
>        and making it do something like objectToArray(this) before
> iterating over the this object?
>        Sorry if i haven´t explained well.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to