-
Notifications
You must be signed in to change notification settings - Fork 71
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
Dictionary>>#asJson does not produce valid JSON when using integer keys #1367
Comments
…ny value used as key in the dictionary to a string.
Hey @koendehondt , Instead of erroring, I opted to convert the key |
I think it is strange 😄, but it is a way to make it work for every object, even if it may not be very useful. That is why I suggested to signal an error in case the Smalltalk dictionary has keys that are not supported. The result is that the array key will be transformed into a string that does not hold a valid JSON array, because |
On second thought I am not happy with it either. The serialisation to a string is different on each platform so that also makes things dodgy. But mind that the key is always a string, and its contents should not be any valid JSON serialisation. Throwing an error is probably the best course of action. But in that case a number should also error, otherwise we are not consistent. The keys in dictionaries you want to convert must then always be strings. This is probably not something we can ship in a bugfix release since it changes the semantics. I'll have to see... |
I agree.
Indeed. |
I updated #1368 |
OK. Thanks @jbrichau. |
…t-produce-valid-JSON-when-using-integer-keys Fix #1367: keys of a JSON object should always be a string. + JSON tests cleanup
Seaside version: 3.5.1
This is fine:
This is not ok, because object property names in JSON should be strings:
In older versions of Seaside, it was correct:
Back then, we had this code:
As you can see in the last method,
key greaseString
ensured that the object property key was a string.In version 3.5.1, we have this code:
In the last method,
key jsonOn: canvas
generates JSON for the key. If the key is an integer, it will generate the integer, not a string as in older versions of Seaside. So this is a regression.It gets worse when the key is an array.
results in an infinite loop. I would agree if one argues that this example is not a real use case, but if so, the code should signal an exception rather than looping infinitely. I did not try other types of object as dictionary keys. I found the above example by playing around after seeing the regression.
The text was updated successfully, but these errors were encountered: