Releases: JohnSundell/Unbox
Unbox 4.0.0
This version moves Unbox to Xcode 10.2 and Swift 5, and with that comes some API changes that will require manual fixes for users adopting this new version.
Since Swift now automatically flattens optionals returned from throwing functions called with try?
, Unbox now uses throwing APIs for all unboxing methods. That means that while in previous versions, you’d unbox an optional property like this:
struct User: Unboxable {
var name: String?
init(unboxer: Unboxer) throws {
name = unboxer.unbox(key: "name")
}
}
You’ll now have to prefix such calls with try?
:
struct User: Unboxable {
var name: String?
init(unboxer: Unboxer) throws {
name = try? unboxer.unbox(key: "name")
}
}
While I realize that the above change brings a slight regression in terms of Unbox’s ease-of-use, it’s necessary in order to make Unbox support the latest Swift tools within a reasonable scope, and also moves Unbox's API to be more inline with modern Swift conventions for throwing methods.
View build details and download artifacts on buddybuild:
Unbox (iOS, Unbox-iOS)
Unbox 3.1.0
This version migrates Unbox to Swift 4.2.
View build details and download artifacts on buddybuild:
Unbox (iOS, Unbox-iOS)
Unbox 3.0.0
This version migrates Unbox to Swift 4.1
View build details and download artifacts on buddybuild:
Unbox (iOS, Unbox-iOS)
Unbox 2.5.0
This version of Unbox adds support for Xcode 9 and Swift 3.2, as well as re-organizes the project to be easier to browse, with separate files for each part of the API. It also enables the tests to be run using the Swift Package Manager.
Unbox 2.4.0
- You can now unbox a dictionary of models directly using the top-level
unbox()
function. Works with bothData
andUnboxableDictionary
. Implemented by @mislavjavor. Decimal
is now a first-class number type, and gets automatically converted from other number types and strings. Implemented by @bencallis.- You can now unbox
Set
directly from an array, without any custom transformation code. Implemented by @hartbit.
Unbox 2.3.1
More unbox()
functions that return an Array
can now (optionally) be passed the allowInvalidElements
parameter.
Unbox 2.3.0
UnboxPathError
is now public, meaning that the detailed error reporting introduced in2.2
has now been combined with the granularity of earlier versions.UnboxError
is again an enum to enable developers toswitch
on the different cases.- Xcode settings have now been updated for
8.1
. No more⚠️ . - Unbox now has a shiny new logo (kind of shiny anyway, I'm not a designer 😁).
- When unboxing
Data
to an array, you can now start unboxing at a certain key path. - Unbox can again be used by dragging
Unbox.swift
directly into a project, instead of using it as a library.
Unbox 2.2.1
This release makes Unbox usable with the new version of the Swift Package Manager.
Unbox 2.2.0
This version is focused on increasing Unbox's speed - it's now up to 50% faster compared to the previous version! It also contains error reporting improvements.
Perfrormance
- Unboxing collections is now up to 25% faster, because of decreased iteration complexity.
- Unboxing with key paths is now up to 50% faster, since associated enum values is no longer used.
The next releases of Unbox will continue to make performance improvements in order to make decoding your JSON even more... eh... swift 😉
Error reporting
Unbox now produces a coherent, easy to read error type. UnboxError
has been made into a struct instead of an enum, and when printed - it produces easily debuggable information.
For example, here's how an invalid array element would be reported in Unbox 2.1 or earlier:
[UnboxError] Invalid value ([1, "Bad value", 3]) for key "array"
And here's how Unbox 2.2 reports the same error:
[UnboxError] An error occured while unboxing path "model.array": Invalid array element ("Bad value") at index 1.
This also means you only have to catch one error type (UnboxError
) instead of performing complex pattern matching.
Unbox 2.1.1
Decimal
can now be unboxed directly (thanks @garnett!)