jarmourato / kodable Goto Github PK
View Code? Open in Web Editor NEWA supercharged extension of Codable
License: MIT License
A supercharged extension of Codable
License: MIT License
Can support CocoaPods?
Hey ๐
I've noticed it's extremely hard to understand errors when you face them. Errors from Decodable provide full context on what went wrong, what was expected and what actually happened, whereas Kodable seems to abstract away that info, effectively leaving the developer clueless.
Example:
โฟ Kodable.KodableError.invalidValueForPropertyWithKey
- invalidValueForPropertyWithKey: "message"
When decoding a complex object, a few questions come to mind:
message
? Which model does it belong to?message
?message
, but the value wasn't the expected one. What value did the JSON contain, for the message
key?Now, compare the same scenario with the Decodable
error:
โฟ DecodingError
โฟ typeMismatch : 2 elements
- .0 : Swift.String
โฟ .1 : Context
โฟ codingPath : 1 element
- 0 : CodingKeys(stringValue: "message", intValue: nil)
- debugDescription : "Expected to decode String but found a number instead."
- underlyingError : nil
Although it doesn't answer questions 1 and 3, it answers 2 pretty clearly, specially with the debugDescription
. Perhaps Kodable could incorporate that information and also help answer question 1 and 3, which would increase developers productivity significantly ๐
What do you think @JARMourato ?
Hey ๐
While using this framework I found that when encoding optional parameters that have a nil value, those values translate to null
values in the resulting JSON, instead of skipping them (as the native Encodable
would). This becomes a problem when submitting such JSONs to PATCH endpoints, as the absence of a key-value pair and the presence of the key with a null value have different meanings.
Is there any way to circumvent this that I missed, or is this a bug that needs to be addressed still? ๐
Looking forward to hearing from you and to continuing using Kodable ๐
you can remove CRuntime.h and create a CBridge.swift file.
add code to CBridge.swift
import Foundation
@_silgen_name("swift_getTypeByMangledNameInContext")
public func swift_getTypeByMangledNameInContext(
_ name: UnsafeMutablePointer<Int8>,
_ nameLength: Int32,
_ genericContext: UnsafeRawPointer?,
_ genericArguments: UnsafeRawPointer?)
-> Any.Type?
@_silgen_name("swift_allocObject")
public func swift_allocObject(
_ type: UnsafeRawPointer?,
_ requiredSize: Int32,
_ requiredAlignmentMask: Int32)
-> UnsafeRawPointer?
hope this will helpful!
Original request:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.