SafeDecoder alternatives and similar libraries
Based on the "JSON" category.
Alternatively, view SafeDecoder alternatives based on common mentions on social networks and blogs.
-
HandyJSON
A handy swift json-object serialization/deserialization library -
AlamofireObjectMapper
An Alamofire extension which converts JSON response data into swift objects using ObjectMapper -
Gloss
[Deprecated] A shiny JSON parsing library in Swift :sparkles: Loved by many from 2015-2021 -
EVReflection
Reflection based (Dictionary, CKRecord, NSManagedObject, Realm, JSON and XML) object mapping with extensions for Alamofire and Moya with RxSwift or ReactiveSwift -
Decodable
[Probably deprecated] Swift 2/3 JSON unmarshalling done (more) right -
JSONHelper
โ Convert anything into anything in one operation; JSON data into class instances, hex strings into UIColor/NSColor, y/n strings to booleans, arrays and dictionaries of these; anything you can make sense of! -
Himotoki
A type-safe JSON decoding library purely written in Swift -
CodableAlamofire
An extension for Alamofire that converts JSON data into Decodable objects. -
Genome
A simple, type safe, failure driven mapping library for serializing JSON to models in Swift 3.0 (Supports Linux) -
Elevate
Elevate is a JSON parsing framework that leverages Swift to make parsing simple, reliable and composable. -
JSONNeverDie
Auto reflection tool from JSON to Model, user friendly JSON encoder / decoder, aims to never die -
ModelRocket
An iOS framework for creating JSON-based models. Written in Swift. -
Tailor
:necktie:A super fast & convenient object mapper tailored for your needs -
AlamofireJsonToObjects
An Alamofire extension which converts JSON response data into swift objects using EVReflection -
Brick
:droplet: A generic view model for both basic and complex scenarios -
PPJSONSerialization
The Ultimate JSON Serialization for Swift. -
JSONParserSwift
Framework for easily parsing your JSON data directly to Swift object. -
JsonSwiftson
A JSON parser with concise API written in Swift.
Appwrite - The open-source backend cloud platform
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of SafeDecoder or a related project?
README
SafeDecoder 
A Codable extension to decode arrays and to catch & log all decoding failures
Features
SafeDecoder makes two improvements for Codable models
- When decoding arrays it can skip over invalid objects, allowing your app to show just valid objects
- It can also collect all the decoding errors and send them to your logging class or service
How to install
Add this to your CocoaPods Podfile
pod 'SafeDecoder'
How to decode arrays
To decode arrays safely, in you model's init(from decoder:) just call container.decodeArray() and pass in the model type in your array
import SafeDecoder
struct MyModel: Decodable {
var myArray: [CGRect]
enum CodingKeys: String, CodingKey {
case myArray
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
// to parse an array without re-thowing an error, call decodeArray()
myArray = try container.decodeArray(CGRect.self, forKey: .myArray)
}
}
How to decode safely
If you want to collect all decoding errors for logging, implement your own logging code here
SafeDecoder.logger = { error, typeName in
// replace with a call to your own logging library/service
print(error)
}
Then in your model's init(from decoder:) call decoder.safeContainer(), then call container.decodeSafe() or container.decodeArraySafe()
SafeDecoder will collect all errors and log them before throwing the exception
import SafeDecoder
struct MyModel: Decodable {
var myId: String
var myArray: [CGRect]
enum CodingKeys: String, CodingKey {
case myId
case myArray
}
public init(from decoder: Decoder) throws {
var container = try decoder.safeContainer(keyedBy: CodingKeys.self)
let _myId = try container.decodeSafe(String.self, forKey: .myId)
let _myArray = try container.decodeArraySafe(CGRect.self, forKey: .myArray)
guard
let myId = _myId,
let myArray = _myArray
else {
// this reference can be your object identifier to help find the issue with your data
throw container.getErrors(modelType: MyModel.self, reference: _myId)
}
self.myId = myId
self.myArray = myArray
}
}
Get these while stocks last :)
An elegant solution for keeping views visible when the keyboard is being shown https://github.com/IdleHandsApps/IHKeyboardAvoiding
Button styles that are centralied and reusable, and hooked up to InterfaceBuilder https://github.com/IdleHandsApps/DesignableButton
An extension to easily set your UINavigationBar transparent and hide the shadow https://github.com/IdleHandsApps/UINavigationBar-Transparent
Author
- Fraser Scott-Morrison ([email protected])
It'd be great to hear about any cool apps that are using SafeDecoder
License
Distributed under the MIT License
*Note that all licence references and agreements mentioned in the SafeDecoder README section above
are relevant to that project's source code only.