Releases: Anviking/Decodable
Releases · Anviking/Decodable
Untitled
TypeMismatch NSNull
- Fixed
ignoredInvalidObjects
typo in Array extension - Marked the
T?
returning overloads as throwing. However they will catch a NSNull TypeMismatch error. - Made
catchNull
andcatchAll
functions public - Added completely non-throwing
=>?
overload returningT?
- Made improvements on how the error path is calculated in nested objects (try and preserve it from the very root object)
- Various minor changes
Simplicity
- Use
\u{0}
-separated string for JSONPaths. This reduces the number of overloads needed. In the future this will make it easier to test and add new overloads with more return-types likeT
,T?
,[T]
...
let a = json => "key1" => "key2" => "key3" // is equivlent to
let a = json => "key1\u{0}key2\u{0}key3"
// NOTE: Never actually do this, the character or implementation details might change.
- Removed
DecodableArray<T> and NilFilteringArray<T>
. Use either:
[T].decode(object, ignoreInvalidObject: false)
// or
decodeArray(ignoreInvalidObjects: false)(json: object)
- Added public
parse()
-function. This is what all the=>
-overloads are calling.
public func parse<T>(json: AnyObject, path: [String], decode: (AnyObject throws -> T)) throws -> T {
NSDictionary
- Favor use of
NSDictionary
instead of[String: AnyObject]
to avoid performance issues caused by converting between the two.
This is madness
- Error Paths!
- More complicated implementation
- Possible to have
[String: Castable]
or [String: AnyObject] as final return type. - Right associativity (implementation detail, should not affect the basic use-cases)
// j => ("a" => ("b" => "c"))
Power of throws
- Simple and straightforward first implementation
String
,Int
,Double
,Bool
,Dictionary
T
,T?
,[T]
,[T]?
- Left associativity
// ((j => "a") => "b") => "c"