跳转至

Rx-toJSON

/// Response -> Observable<JSON>
///
/// - Parameter modelKey: 模型数据路径
func toJSON(modelKey: String? = nil) -> Observable<JSON>

func toJSON(modelKey: String? = nil) -> Single<JSON>

详细说明请参考 Core 目录下的 toJSON ,这里就不再赘述


let rxRequest: Single<Response>

success-obj

rxRequest.toJSON(modelKey: "retBody")
    .subscribe(onSuccess: { json in
        let name = json["author"].stringValue
        let age = json["age"].intValue
        print("author -- \(name)")
        print("age -- \(age)")
    }).disposed(by: disposeBag)

打印结果

author -- LinXunFeng
age -- 23