Bump version to 2.0.0
RxSwift wrapper for JSON.
This is an example of converting a json dictionary observable to a string observable:
URLSession.shared.rx.json(url: "https://api.github.com/repos/ReactorKit/ReactorKit") .mapJSON("owner") // Observable<Any> -> Observable<Any> .mapJSON("login", String.self) // Observable<Any> -> Observable<String> .bind(to: ownerNameLabel.rx.text)
mapJSON() supports both JSON dictionary and array:
mapJSON()
// Dictionary Observable<Any>.mapJSON("key") // Observable<Any> Observable<Any>.mapJSON("key", Int.self) // Observable<Int> // Array Observable<Any>.mapJSON(at: 2) // Observable<Any> Observable<Any>.mapJSON(at: 3, String.self) // Observable<String>
mapJSON() will throw a RxJSONError when there’s no value for given accessor or fails to cast to a given type:
RxJSONError
// Dictionary source.mapJSON("unknownKey") // Event.error(RxJSONError.valueNotFound) source.mapJSON("name", Int.key) // Event.error(RxJSONError.castingFailed) // Array source.mapJSON(at: -1) // Event.error(RxJSONError.valueNotFound) source.mapJSON(at: 0, Int.key) // Event.error(RxJSONError.castingFailed)
Using CocoaPods:
pod 'RxJSON'
Using Carthage:
This is not supported yet. See [Carthage#1945](https://github.com/Carthage/Carthage/pull/1945) for details.
Any discussions and pull requests are welcomed 💖
To create a Xcode project:
$ swift package generate-xcodeproj
RxJSON is under MIT license. See the LICENSE file for more info.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
RxJSON
RxSwift wrapper for JSON.
At a Glance
This is an example of converting a json dictionary observable to a string observable:
mapJSON()
supports both JSON dictionary and array:mapJSON()
will throw aRxJSONError
when there’s no value for given accessor or fails to cast to a given type:Installation
Using CocoaPods:
Using Carthage:
Contributing
Any discussions and pull requests are welcomed 💖
To create a Xcode project:
License
RxJSON is under MIT license. See the LICENSE file for more info.