IMHO equals should fullfill the spec - so equals should return true (and hashcode) should return the same value. Ordering of values is a propietary feature which can be used for explicit functionality like a userdefined displayorder. Adding restrictions by undefined (but common) behaviour might not be the best idea.
Best regards, Dominik On Sun, Jun 7, 2009 at 8:40 PM, Felix Meschberger <fmesc...@gmail.com>wrote: > Hi, > > Alexander Klimetschek schrieb: > > On Sat, Jun 6, 2009 at 5:55 PM, Felix Meschberger<fmesc...@gmail.com> > wrote: > >>> On Fri, Jun 05, 2009 at 09:18:05PM +0200, Alexander Klimetschek wrote: > >>>> I think they are not equivalent in the strict Javascript sense, as the > >>>> order of the properties in an object is defined (you can iterate over > >>>> it). It is not to be seen as a pure hash map. > >> This is wrong. The spec explicitly states that there is no defined order > >> amongst the properties of an object. > >> > >> Now, in reality, the known browsers implement objects in a way, that the > >> properties have a factual insertion order. But, this is an > >> implementation specific thing. > > > > Ok, I didn't know it was specified as free. But since the popular > > implementations (browsers) all follow the same way, ie. keep the order > > (in Javascript), one should follow this to keep free from unwanted > > problems. > > I do not agree. One should follow the spec and consider the browser > implementations what they are: implementations of the spec where it > happens to be that the properties seem to have an order. > > But yes, the Sling JSONObject also supports the property ordering due to > popular request of users depending on this implementation specific... > > Regards > Felix >