Re: [swift-corelibs-dev] Adding type conversion capabilities to JSON encode/decode

2017-08-30 Thread Youming Lin via swift-corelibs-dev
Brandon Sorry, I didn't realize you want it on the String type since you used other string ivars in your example as well. I'm not sure that forcing all numbers to be valid decoded strings is a good idea, because this behavior gets applied to other string ivars that you may not want to be compatib

Re: [swift-corelibs-dev] Adding type conversion capabilities to JSON encode/decode

2017-08-30 Thread Youming Lin via swift-corelibs-dev
Brandon I cooked up a simple example and it works as expected. ylin@youming-mbpr:~/Swift/Configuration$ swift Welcome to Apple Swift version 4.0-dev (LLVM 2dedb62a0b, Clang b9d76a314c, Swift 0899bd328a). Type :help for assistance. 1> import Foundation 2> struct A: Codable { 3. var integ

Re: [swift-corelibs-dev] Adding type conversion capabilities to JSON encode/decode

2017-08-30 Thread Youming Lin via swift-corelibs-dev
Brandon >JSON’s types effectively end up matching specifically to primitives, of which there is no mechanism to override the behavior of how a String gets decoded for instance. You can override the default behavior with your own custom init(from:) implementation for your Codable struct: https://d

Re: [swift-corelibs-dev] Adding type conversion capabilities to JSONencode/decode

2017-08-30 Thread Youming Lin via swift-corelibs-dev
One downside I see is that the encoder wouldn't know if this specific field was originally a number instead of a string. If the same Codable struct is used for GET and POST, for example, the post-encode JSON string could be invalid because the server expects a number instead of a string for that fi

Re: [swift-corelibs-dev] TimeZone database

2017-07-06 Thread Youming Lin via swift-corelibs-dev
was never installed as part of the base. An ‘apt-get install tzdata’ might fix it. Simon On 6 Jul 2017, at 20:20, Youming Lin via swift-corelibs-dev < swift-corelibs-dev@swift.org> wrote: That's odd. Maybe my ubuntu:16.04 image is outdated or something, but

Re: [swift-corelibs-dev] TimeZone database

2017-07-06 Thread Youming Lin via swift-corelibs-dev
That's odd. Maybe my ubuntu:16.04 image is outdated or something, but here are my outputs: ylin@youming-mbpr:~/Swift/Kitura-Markdown$ docker run -it --rm ubuntu:16.04 find /usr -name zone.tab ylin@youming-mbpr:~/Swift/Kitura-Markdown$ docker run -it --rm ubuntu:14.04 find /usr -name zone.tab /usr/

Re: [swift-corelibs-dev] TimeZone database

2017-07-06 Thread Youming Lin via swift-corelibs-dev
We were seeing this on Travis too. Specifically, on a Travis matrix build using Swift 3.1.1 on a Ubuntu 16.04 docker image running inside a Travis 14.04 VM. The issue was specific to the Ubuntu 16.04 docker image; when I tested in Ubuntu 16.04 OS as a guest VM, the issue went away. Thanks, Youmi