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

[SR-10630] JSONDecoder convertToSnakeCase no longer converts dictionary keys #3422

Open
swift-ci opened this issue May 6, 2019 · 4 comments

Comments

@swift-ci
Copy link
Contributor

swift-ci commented May 6, 2019

Previous ID SR-10630
Radar None
Original Reporter stjernegard (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode 10.2.1 (10E1001)
Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
Target: x86_64-apple-darwin18.5.0

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug, Codable
Assignee bendjones (JIRA)
Priority Medium

md5: 5efcc4caa9e3495f987fbfb0a346bfdf

relates to:

  • SR-7360 keyDecodingStrategy breaks dictionary-keys

Issue Description:

JSONDecoder has regressed between Swift 4.2.4 and Swift 5.0.

Encoding the value ["camelCase": 1] with .convertToSnakeCase would convert the key in Swift 4, but no longer does so in Swift 5.

I can't find anything in the release notes suggesting that this is an expected outcome.

A Swift file showing the issue is attached.

➤ ./swift-4.2.4-RELEASE.xctoolchain/usr/bin/swift ~/test.swift
{"camel_case":1}

➤ ./swift-5.0-RELEASE.xctoolchain/usr/bin/swift ~/test.swift
{"camelCase":1}
@belkadan
Copy link

belkadan commented May 6, 2019

cc bendjones (JIRA User), @millenomi

@swift-ci
Copy link
Contributor Author

swift-ci commented May 6, 2019

Comment by Ben D. Jones (JIRA)

Thanks @belkadan I'll take a look.

@itaiferber
Copy link
Contributor

This was a purposeful fix for SR-7360 made in PR-16238

@swift-ci
Copy link
Contributor Author

swift-ci commented May 6, 2019

Comment by Danni Stjernegård (JIRA)

I see that the old behavior was deemed a bug after a long discussion on the forums. Up until then multiple people, including @belkadan and @itaiferber called it correct and expected behavior.

I've spent the entire day fire fighting after this slipped through our testing and am not sure how we should have noticed the change without combing through the forums.

It was never mentioned in the changelog and I'm seeing that the corelibs-foundation team didn't notice either until just 13 days ago.

Changes like this, that not only breaks existing code, but does so in a way that's not possible to detect by the compiler, would be very appreciated if given a mention a bit more noticeably.

Even searching Google for information, I'm finding nothing except for the forum thread where the change was agreed on. Nothing on the official documentation either.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants