New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
order based pseudo classes shouldn't match object children. #1
Comments
Fixing enumeration order of JS objects won't affect the "semantics" of JSON, because JSON has no semantics. It's just a grammar. So Rob's example from Python would still be relevant. Note that this is a fantastic example of why semantics matters. Should objects be treated as ordered? Well, the spec informally claims in its introduction that "an object is an unordered collection of zero or more name/value pairs" but it never actually specifies this anywhere. Dave |
That's right, even if we built normalization into jsonselect implementations, they would be re-ordering json on the wire and the order-dependent pseudo classes available to users have even less value. My proper course of action stills seems to be to say order based pseudo classes shouldn't match object children. Anyone who serializes JSON with meaning applied to object key order deserves what they get! |
Yes, they would be re-ordering JSON on the wire. Exactly. But it gets worse. :) You don't need any order-based selectors: just use numeric keys, always. They work for objects and arrays. Imagine this JS shell session:
So, one time, I went down this path in https://github.com/sayrer/json-sync , but with more of an XPath flavor. I think Crockford also digs something similar: JSONPath. See http://www.crockford.com/misty/json.html I can see why your way is something of a hit, what with the JQuery synergy. One thing I've learned is that Resig's way will always be more popular than anything I make up. :) |
Rob Sayre mentioned a flaw in the design of JSONSelect. Specifically that there in not a reliable and widely implemented method of normalizing property order in JSON objects.
The fallout of this is that the application of order dependant pseudo classes (like
:first-child
,:nth-child()
, etc), can be unreliable and can vary depending on the serialization of the object.This should result in two changes to JSONSelect:
NOTE: Brendan Eich mentions that a tighter definition about canonical property order is in progress, but in order for JSONSelect to be immediately useful, I still think ripping this feature out is the right thing to do.
Gonna leave this bug open for a bit for thoughts....
The text was updated successfully, but these errors were encountered: