SafeDecoder alternatives and similar libraries
Based on the "JSON" category.
Alternatively, view SafeDecoder alternatives based on common mentions on social networks and blogs.
-
AlamofireObjectMapper
An Alamofire extension which converts JSON response data into swift objects using ObjectMapper -
Gloss
DISCONTINUED. [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 -
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! -
CodableAlamofire
DISCONTINUED. 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 -
AlamofireJsonToObjects
An Alamofire extension which converts JSON response data into swift objects using EVReflection -
DynamicUI
Create a SwiftUI user interface through a JSON file. The JSON file will contain the structure of the user interface, and the program will create the user interface based on the JSON file.
InfluxDB - Purpose built for real-time analytics at any scale.
* 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.