ReactiveSwift JSON parsing helpers for Swift 4 JSON decoding. Inspired by: ReactiveMapper
ReactiveCodable supports JSON mapping for ReactiveSwift on values in a Signal
or SignalProducer
stream.
// Create model from a JSON dictionary
let jsonSignalProducer: SignalProducer<Data, NSError> = // ...
jsonSignalProducer.mapToType(User.self).startWithResult { result in
// use the decoded User model
let user: User? = result.value
}
// Create array of models from array of JSON dictionaries
let jsonSignalProducer: SignalProducer<Any, NSError> = // ...
jsonSignalProducer.mapToType([Task].self).startWithResult { result in
// use the decoded array of Task models
let tasks: [Task]? = result.value
}
Current Swift compatibility breakdown:
Swift Version | Framework Version |
---|---|
4.x | 1.x |
Add the following line to your Cartfile.
github "gunterhager/ReactiveCodable"
Then run carthage update
.