-
Notifications
You must be signed in to change notification settings - Fork 1
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
Json
produces invalid JSON output for integer keys
#109
Comments
Looking at https://www.json.org/json-en.html & https://jsonlint.com/ I think the expectation is that the key must be a string and the value must be the json-ised value, so
should result in an error. Consider the first EBNF diagram on https://www.json.org/json-en.html - it can be simplified for this case to Since we're exceptionally clever we could consider doing "make the key be a string of whatever we have" except that trying to reliably convert non-string keys might open up entire pallet-loads of worms. What if somebody is making dictionaries where the keys are complex objects? Might also want to check on STON as well (https://wiki.squeak.org/squeak/6504). If we're attempting to produce sometihng that meets a standard we should probably actually meet the standard... |
The second should raise an error. Our dictionaries do not preserve insertion order so we don't even know which one is the duplicate. For the first case where it's unambiguous I'd find it more convenient to allow this and automatically convert the key to a string, just like |
I'm personally rather with Tim on that. Let's not bring the joy of
Oh yes indeed. I placed an #isThisEverCalled in this method in my image and if we do not identify any surprising usages, I support removing this method (or deprecating it at least). |
IMO To be specific wrt the test cases from the top post here: the first case should signal an error during |
There are other kinds of invalid keys, such as |
That's not an invalid key: it should serialize to
for example. So long as it's a valid JSON string, it should be a valid JSON key. |
My bad. I tested it in JavaScript and Python but forgot to escape the backslash ... |
What would be the expected behavior?
'{"1":2}'
⭐What in this case?
'{"1":2}'
'{"1":"2"}'
⭐My tendency would be the variants with a star ...
The text was updated successfully, but these errors were encountered: