[Proto-Scripty] Re: Adding method to Object to be able to iterate over a json property

2009-05-29 Thread Richard Quadling
2009/5/29 disccomp : > > I came across this quirk in PHP as well. IMHO, it is much better to > fix the code on the server side than it would be to mess with > (correctly functioning) code on the client. -Mark > > > "Quirk"? I don't think this is a quirk. At what stage should a string be automati

[Proto-Scripty] Re: Adding method to Object to be able to iterate over a json property

2009-05-29 Thread disccomp
I came across this quirk in PHP as well. IMHO, it is much better to fix the code on the server side than it would be to mess with (correctly functioning) code on the client. -Mark --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Goog

[Proto-Scripty] Re: Adding method to Object to be able to iterate over a json property

2009-05-29 Thread T.J. Crowder
Hi, A brief OT before the actual question, you can make your each call more efficient. Instead of: objectToArray(json.element).each(function(ele){ ... }.bind (this)); use each's second param, 'context': objectToArray(json.element).each(function(ele){ ... }, this); Enumerable#each wil

[Proto-Scripty] Re: Adding method to Object to be able to iterate over a json property

2009-05-29 Thread Richard Quadling
2009/5/29 dgalvez : > >  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' >      } > >