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
letjsonSignalProducer:SignalProducer<Data,NSError>= // ...
jsonSignalProducer.mapToType(User.self).startWithResult{ result in
// use the decoded User model
letuser:User?= result.value
}
// Create array of models from array of JSON dictionaries
letjsonSignalProducer:SignalProducer<Any,NSError>= // ...
jsonSignalProducer.mapToType([Task].self).startWithResult{ result in
// use the decoded array of Task models
lettasks:[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.