[swift-users] I ve found a serious Bug in JSONEncoder (SR-6131) and would like to fix it.

David Hart david at hartbit.com
Mon Dec 18 07:23:24 CST 2017


Hello!

Thanks for noticing a bug and taking the time to fix it :) Here are the steps for contributing:

Fork the project (you’ve already done that).
Clone the fork to your computer.
Branch off master and name the branch after the fix (I like to name them with the sr number).
Write the fix and the test that validates it (i <https://github.com/swift-corelibs-foundation/blob/master/Docs/GettingStarted.md>f you’re looking for help here, you can read this documentation from the corelibs foundation repo: https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/GettingStarted.md)
Push your branch to the remote.
On GitHub, open a Pull Request and wait for somebody to look into it.

If anybody notices that I’ve forgotten a step, please let me know. Meanwhile, if you need any help Benoit, I’m available to chat (in French or English) on the SwiftPM Slack at https://swift-package-manager.herokuapp.com <https://swift-package-manager.herokuapp.com/>

Regards,
David Hart.

> On 18 Dec 2017, at 11:34, Benoit Pereira da silva via swift-users <swift-users at swift.org> wrote:
> 
> Dear all
> 
> I've found a serious Bug in JSONEncoder SR-6131 <https://bugs.swift.org/browse/SR-6631> and would like to fix it.
> This bug cause JSON encoding issues on Double when using a local that does not use dot as decimal separator e.g « fr_FR » (we use a coma)
> 
> Demonstration of the issue : 
> 
> import Foundation
> 
> // Required to call setLocale
> import Darwin
> 
> // Let's set to french
> setlocale(LC_ALL,"fr_FR")
>  
> struct Shot:Codable{
>     let seconds:Double
> }
>  
> let shot = Shot(seconds: 1.1)
>  
> do{
>     let data = try JSONEncoder().encode(shot)
>     if let json =  String(data:data, encoding:.utf8){
>         // the result is : "{"seconds":1,1000000000000001} »
> 	// should be : "{"seconds":1.1000000000000001} »
>         // The decimal separator should not be "," but "."
>         print(json)
>     }
> }catch{
>     print("\(error)")
> }
>  
> exit(EX_OK)
> 
> 
> 
> 
> I would like to propose my fix, test it and, but i’m not mastering the contribution mechanism.
> 
> Where should i start? 
> 
> I ve forked https://github.com/benoit-pereira-da-silva/swift-corelibs-foundation <https://github.com/benoit-pereira-da-silva/swift-corelibs-foundation>
> I have a very simple Unit test that demonstrates the issue.
> 
> How can i test my 
> 
> 
> Thanks
> 
> 
> 
> 
> 
> Benoit Pereira da Silva
> Ultra Mobile Developer & Movement Activist
> Développeur Ultra Mobile & Militant du mouvement
> https://pereira-da-silva.com <https://pereira-da-silva.com/>
> 
> <bannerp.jpg>
> 
> 
> 
> ✄ --------------------------------
> This e-mail is confidential. Distribution, copy, publication or use of this information for any purpose is prohibited without agreement of the sender.
> Ce message est confidentiel. Toute distribution, copie, publication ou usage des informations contenues dans ce message sont interdits sans agrément préalable de l’expéditeur.
> 
> 
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20171218/3610dfe0/attachment.html>


More information about the swift-users mailing list