Skip to content
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

Fix #1367: keys of a JSON object should always be a string. + JSON tests cleanup #1368

Conversation

jbrichau
Copy link
Member

@jbrichau jbrichau commented Jun 16, 2023

JSON object keys must be strings. The Seaside JSON writer did not respect this. This PR now allows to only convert dictionaries with String keys, when a flag is set. Otherwise an error is thrown. The idea is to remove the flag in the next major version of Seaside, but already introduce the behavior now so people have a migration path.

Fixes #1367

Also added test to show the WAJsonParser did not accept numbers as keys (which is correct, but inconsistent with the JSON writer).

Also removed the Pharo70-JSON package with an extension for OrderedDictionary and moved it to Pharo-JSON. I noticed this because of failing test for Pharo 7. Since OrderedDictionary is part of Pharo since Pharo 7 and we dropped Pharo 6 and earlier some time ago, this can now reside in the Pharo-JSON package.

FInally, refactored tests for JSON to remove the override of assert:equals: and replaced it with assert:gives:

…ny value used as key in the dictionary to a string.
@jbrichau jbrichau requested a review from marschall June 16, 2023 17:49
@codecov
Copy link

codecov bot commented Jun 16, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03 🎉

Comparison is base (2037d0c) 54.11% compared to head (2f6e405) 54.14%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1368      +/-   ##
==========================================
+ Coverage   54.11%   54.14%   +0.03%     
==========================================
  Files        8871     8876       +5     
  Lines       72049    72097      +48     
==========================================
+ Hits        38989    39037      +48     
  Misses      33060    33060              
Impacted Files Coverage Δ
...re.package/Object.extension/instance/jsonKeyOn..st 100.00% <100.00%> (ø)
...re.package/String.extension/instance/jsonKeyOn..st 100.00% <100.00%> (ø)
...re.package/WAJsonCanvas.class/instance/boolean..st 100.00% <100.00%> (ø)
...ackage/WAJsonCanvas.class/instance/dateAndTime..st 100.00% <100.00%> (ø)
...N-Core.package/WAJsonCanvas.class/instance/null.st 100.00% <100.00%> (ø)
...ore.package/WAJsonCanvas.class/instance/number..st 100.00% <100.00%> (ø)
...kage/WAJsonCanvas.class/instance/scaledDecimal..st 100.00% <100.00%> (ø)
...ore.package/WAJsonCanvas.class/instance/string..st 100.00% <100.00%> (ø)
...WAJsonKeyValueBrush.class/class/stringKeysOnly..st 100.00% <100.00%> (ø)
.../WAJsonKeyValueBrush.class/class/stringKeysOnly.st 100.00% <100.00%> (ø)
... and 35 more

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

… other than strings. In this way, we can introduce the change while keeping backwards compatibility.
…ts for OrderedDictionary to Pharo-JSON package
@jbrichau jbrichau changed the title Fix #1367: keys of a JSON object should always be a string. Fix #1367: keys of a JSON object should always be a string. + JSON tests cleanup Jun 25, 2023
@jbrichau jbrichau merged commit d0d3289 into master Jun 27, 2023
15 of 22 checks passed
@jbrichau jbrichau deleted the 1367-DictionaryasJson-does-not-produce-valid-JSON-when-using-integer-keys branch June 27, 2023 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dictionary>>#asJson does not produce valid JSON when using integer keys
1 participant