Closed jkufver closed 6 years ago
I receive runtimeHours as json to my app;
{ ... "runtimeHours": 1234, ... }
In my model the value is an optional Double. I found that my values always is nil using this code:
runtimeHours = try? json.decode(["runtimeHours"])
I thinks this is a bug, 1234 should be treated as a valid Double.
If I do try! instead the exception is:
try!
Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: Juice.DictionaryDecodingError(keyPath: ["runtimeHours"], underlyingError: Juice.MismatchError.typeMismatch(expected: Swift.Double, got: 1234))
Finally, my workaround now is this:
if let intValue: Int = try? json.decode(["runtimeHours"]) { runtimeHours = Double(intValue) } else { runtimeHours = try? json.decode(["runtimeHours"]) }
BTW, I like your pod a lot. Cheers.
Oops, didn't see this until now. Yes, I would also call this a bug, fixed in 1.0.9!
I receive runtimeHours as json to my app;
In my model the value is an optional Double. I found that my values always is nil using this code:
I thinks this is a bug, 1234 should be treated as a valid Double.
If I do
try!
instead the exception is:Finally, my workaround now is this:
BTW, I like your pod a lot. Cheers.