SeasideSt / Seaside

The framework for developing sophisticated web applications in Smalltalk.
MIT License
519 stars 71 forks source link

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

Closed jbrichau closed 1 year ago

jbrichau commented 1 year ago

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:

codecov[bot] commented 1 year ago

Codecov Report

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

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

Additional details and impacted files ```diff @@ 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](https://app.codecov.io/gh/SeasideSt/Seaside/pull/1368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SeasideSt) | Coverage Δ | | |---|---|---| | [...re.package/Object.extension/instance/jsonKeyOn..st](https://app.codecov.io/gh/SeasideSt/Seaside/pull/1368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SeasideSt#diff-cmVwb3NpdG9yeS9TZWFzaWRlLUpTT04tQ29yZS5wYWNrYWdlL09iamVjdC5leHRlbnNpb24vaW5zdGFuY2UvanNvbktleU9uLi5zdA==) | `100.00% <100.00%> (ø)` | | | [...re.package/String.extension/instance/jsonKeyOn..st](https://app.codecov.io/gh/SeasideSt/Seaside/pull/1368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SeasideSt#diff-cmVwb3NpdG9yeS9TZWFzaWRlLUpTT04tQ29yZS5wYWNrYWdlL1N0cmluZy5leHRlbnNpb24vaW5zdGFuY2UvanNvbktleU9uLi5zdA==) | `100.00% <100.00%> (ø)` | | | [...re.package/WAJsonCanvas.class/instance/boolean..st](https://app.codecov.io/gh/SeasideSt/Seaside/pull/1368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SeasideSt#diff-cmVwb3NpdG9yeS9TZWFzaWRlLUpTT04tQ29yZS5wYWNrYWdlL1dBSnNvbkNhbnZhcy5jbGFzcy9pbnN0YW5jZS9ib29sZWFuLi5zdA==) | `100.00% <100.00%> (ø)` | | | [...ackage/WAJsonCanvas.class/instance/dateAndTime..st](https://app.codecov.io/gh/SeasideSt/Seaside/pull/1368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SeasideSt#diff-cmVwb3NpdG9yeS9TZWFzaWRlLUpTT04tQ29yZS5wYWNrYWdlL1dBSnNvbkNhbnZhcy5jbGFzcy9pbnN0YW5jZS9kYXRlQW5kVGltZS4uc3Q=) | `100.00% <100.00%> (ø)` | | | [...N-Core.package/WAJsonCanvas.class/instance/null.st](https://app.codecov.io/gh/SeasideSt/Seaside/pull/1368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SeasideSt#diff-cmVwb3NpdG9yeS9TZWFzaWRlLUpTT04tQ29yZS5wYWNrYWdlL1dBSnNvbkNhbnZhcy5jbGFzcy9pbnN0YW5jZS9udWxsLnN0) | `100.00% <100.00%> (ø)` | | | [...ore.package/WAJsonCanvas.class/instance/number..st](https://app.codecov.io/gh/SeasideSt/Seaside/pull/1368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SeasideSt#diff-cmVwb3NpdG9yeS9TZWFzaWRlLUpTT04tQ29yZS5wYWNrYWdlL1dBSnNvbkNhbnZhcy5jbGFzcy9pbnN0YW5jZS9udW1iZXIuLnN0) | `100.00% <100.00%> (ø)` | | | [...kage/WAJsonCanvas.class/instance/scaledDecimal..st](https://app.codecov.io/gh/SeasideSt/Seaside/pull/1368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SeasideSt#diff-cmVwb3NpdG9yeS9TZWFzaWRlLUpTT04tQ29yZS5wYWNrYWdlL1dBSnNvbkNhbnZhcy5jbGFzcy9pbnN0YW5jZS9zY2FsZWREZWNpbWFsLi5zdA==) | `100.00% <100.00%> (ø)` | | | [...ore.package/WAJsonCanvas.class/instance/string..st](https://app.codecov.io/gh/SeasideSt/Seaside/pull/1368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SeasideSt#diff-cmVwb3NpdG9yeS9TZWFzaWRlLUpTT04tQ29yZS5wYWNrYWdlL1dBSnNvbkNhbnZhcy5jbGFzcy9pbnN0YW5jZS9zdHJpbmcuLnN0) | `100.00% <100.00%> (ø)` | | | [...WAJsonKeyValueBrush.class/class/stringKeysOnly..st](https://app.codecov.io/gh/SeasideSt/Seaside/pull/1368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SeasideSt#diff-cmVwb3NpdG9yeS9TZWFzaWRlLUpTT04tQ29yZS5wYWNrYWdlL1dBSnNvbktleVZhbHVlQnJ1c2guY2xhc3MvY2xhc3Mvc3RyaW5nS2V5c09ubHkuLnN0) | `100.00% <100.00%> (ø)` | | | [.../WAJsonKeyValueBrush.class/class/stringKeysOnly.st](https://app.codecov.io/gh/SeasideSt/Seaside/pull/1368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SeasideSt#diff-cmVwb3NpdG9yeS9TZWFzaWRlLUpTT04tQ29yZS5wYWNrYWdlL1dBSnNvbktleVZhbHVlQnJ1c2guY2xhc3MvY2xhc3Mvc3RyaW5nS2V5c09ubHkuc3Q=) | `100.00% <100.00%> (ø)` | | | ... and [35 more](https://app.codecov.io/gh/SeasideSt/Seaside/pull/1368?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SeasideSt) | |

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