Releases: JohnSundell/Unbox
Unbox 2.1
- You can now manually create
Unboxer
instances with either anUnboxableDictionary
orData
. This gives you more flexibility and control over the unboxing process (compared to callingunbox()
, which makes Unbox create anUnboxer
for you). - Unbox now correctly handles
Int32
,Int64
,UInt32
andUInt64
, even on 32 bit systems.
Unbox 2.0
Unbox 2.0 brings a new, streamlined API and reworked internals for maximum flexibility & performance.
swift2
branch.
All APIs have been reworked to follow the Swift 3 API naming guidelines
Unbox(_)
is nowunbox(dictionary:)
,unbox(data:)
andunbox(dictionaries:)
.UnboxableWithContext.ContextType
is nowUnboxContext
.UnboxableByTransform.UnboxRawValueType
is nowUnboxRawValue
.- Wherever key paths were supported with the
isKeyPath:
argument, that has now been replaced withkey:
andkeyPath:
overloads. For exampleunboxer.unbox("company.title", isKeyPath: true)
is nowunboxer.unbox(keyPath: "company.title")
. - The
UnboxError
enum now uses non-captailized first letters for its cases. UnboxableKey.transformUnboxedKey()
is nowtransform(unboxedKey:)
.UnboxableByTransform.transformUnboxedValue()
is nowtransform(unboxedValue:)
.UnboxFormatter.formatUnboxedValue()
is nowformat(unboxedValue:)
.Unboxer.performCustomUnboxingWithDictionary()
is nowperformCustomUnboxing(dictionary:)
Unboxer.performCustomUnboxingWithArray()
is nowperformCustomUnboxing(array:)
Unboxer.performCustomUnboxingWithData()
is nowperformCustomUnboxing(data:)
Swift native error handling model
Unboxable
and UnboxableWithContext
types can now throw from their initializer. This enables you to easily manually exit from an initializer, without having to use any specific APIs on Unboxer
.
This new capability is also used when performing unboxing of values. Now, all required properties are unboxed using try
, meaning that as soon as an error as been encountered, the initializer will be exited. This gives us a huge performance boost when dealing with malformed data, or when allowing invalid elements.
It also means that the unboxFallbackValue()
function has been removed, and is no longer required to be implemented by types.
Finally, since now only one error can be thrown from an unboxing process (since we exit early) - UnboxError
and UnboxValueError
have been merged, and there's no longer a hasFailed
property on Unboxer
.
Any combination of arrays & dictionaries are now directly unboxable
Previously, Unbox only supported combinations of types and collections that were defined as overloads on Unboxer
. Now, thanks to a reworked value resolving system, any combination of types and collections are supported. You can now directly unbox even the most complex data structures with one simple call to unbox()
.
Removals
Some APIs that have been kept around for legacy reasons have been removed in this release.
- You can no longer send a
context
when starting the unboxing process forUnboxable
types. Instead, useUnboxableWithContext
, which gives you strong typing for your contextual object. UnboxableWithFormatter
has been removed, since it wasn't needed. Formatting is still 100% supported, through the use of theUnboxFormatter
API.
Unbox 1.9
- You can now Unbox an array of
UnboxableByTransform
types (thanks @maxsz!) - You can now start Unboxing at a certain key/keyPath instead of having to create an intermediate struct (thanks @clayellis!)
- You can now send a context when unboxing a nested
Unboxable
type. - An array of strings can now be directly unboxed to an array of another raw type (thanks @clayellis!)
Unbox 1.8
This release contains great new features implemented by the ever growing Unbox community!
- The custom unboxing API for arrays now supports allowing invalid elements (like the other array-based APIs). Thanks to @PSchu!
- Nested dictionary support has been heavily improved (they can, for instance, now contain nested arrays in turn, making you able to unbox a deep structure in one go). Thanks @johannth!
- You can now directly unbox an array with values that will be formatted using a formatter (and optionally allowing invalid elements too!). Thanks to @mikezs!
Unbox 1.7 - 1 year anniversary edition!
Unbox is 1 year old today, let's celebrate with a release 🎉
- Unbox can now automatically convert most numbers to their expected type. The following types are supported:
Ints, Bool, UInt, Int32, Int64, Double, Float
. - The
isKeyPath
parameter's default value is nowtrue
, meaning that in order to use keypaths, less code needs to be written.
Unbox 1.6
-
Errors for missing and/or invalid values are now thrown as an array, so that you can see all errors that were encountered at once - reducing debugging times! Thanks @Evertt for implementing this!
-
An
UnboxableByTransform
's raw type can now be a collection (so you can use it to transform not only raw values, but also collections). -
Type safety for Arrays & Dictionaries has been improved. They can now only be unboxed if they:
A) Are explicitly typed as [AnyObject] or [String : AnyObject]
B) Contain only raw values (like Int, String, etc)
C) Contain nested collections
Unbox 1.5.2
This release contains fixes from the evergrowing Unbox community! 🚀
- Swift Package Manager (SPM) is now supported (thanks @alexaubry!)
- OS X 10.10 is now supported, just as 10.11 (thanks @bmichotte!)
- Custom unboxing closures can now throw (thanks @pureblood!)
Unbox 1.5.1
- Key path based unboxing now supports retrieving an element from a nested array (thanks @BalestraPatrick for implementing this!)
- Unbox will now automatically convert strings to numbers if you're expecting a number type and a string was found.
Unbox 1.5
This release makes improvements to the main Unbox()
API, as well as when working with collections.
Unbox()
andUnboxOrThrow()
have been merged intoUnbox()
- that is now a throwing function. The same behavior as when usingUnboxOrThrow()
can still be achieved usingtry? Unbox()
.- When unboxing an array or dictionary containing
Unboxable
dictionaries, anallowInvalidElements
parameter has been added, to optionally (it defaults tofalse
) skip invalid elements that couldn't be unboxed - and instead of failing the process returning a collection with all valid elements. - Unbox now supports collections with nested collections inside of them.
- The project now uses single plist files for tests and for the framework.
Thanks to @basememara, @acecilia, @Abizern for their work on this release 🎉
Unbox 1.4
This release mostly includes improvements by the growing Unbox community 🚀