[swift-users] Getting ambiguous error only when override Int decoder

2017-11-07 Thread Solli Honorio via swift-users
I'm trying to override some decode parsers from KeyedDecodingContainer, but I getting a stranger ambiguous error. Is stranger for me, because I'm getting this message error only on *Int* and *Double* override parse. I appreciate any help because I don't know why the Float parse works and Int got t

Re: [swift-users] Decoding dates with dateDecodingStrategy

2017-10-23 Thread Solli Honorio via swift-users
Ray, For now, my strategy to date decoding is configuring let decoder = JSONDecoder() decoder.dateDecodingStrategy = JSONDecoder.DateDecodingStrategy.custom({ foo -> Date in let container = try foo.singleValueContainer() let dateStr = try container.decode(String.self) return myCustomDateParse(da

[swift-users] What is the better way to override KeyedDecodingContainer.decode ?

2017-10-23 Thread Solli Honorio via swift-users
Codable is great and I'm moving to it, but sometimes server return numbers as a string and I have to force the parser to take care of this behavior. I would like your opinion if this is the better solution to parse numbers even when I got string. Thanks, Solli Honorio import Foundation extens

Re: [swift-users] Where CodingKey protocol is implemented on swift source code

2017-10-04 Thread Solli Honorio via swift-users
com/apple/swift/blob/master/lib/Sema/DerivedConformanceCodingKey.cpp> > . > > Happy to answer any questions on this you might have. > > — Itai > > On 4 Oct 2017, at 14:50, Solli Honorio via swift-users wrote: > > Studying "Codable.swift" and "JSONEncoder.swift"

[swift-users] Where CodingKey protocol is implemented on swift source code

2017-10-04 Thread Solli Honorio via swift-users
Studying "Codable.swift" and "JSONEncoder.swift" to understand how decoding works under the hood, I got confused about how CodingKey is implemented for 'enum'. Shouldn't have an extension of RawRepresentable to implement the CodingKey protocol? This is the answer I'm looking for, how the CodingKey