跳转至

Rx-fetchString

/// 获取指定路径的字符串
///
/// - Parameters:
///   - path: JSON数据路径 (默认为模型数据路径)
///   - keys: 目标数据子路径  (例: [0, "_id"])
func fetchString(path: String? = nil, keys: [JSONSubscriptType] = []) -> Observable<String>

func fetchString(path: String? = nil, keys: [JSONSubscriptType] = []) -> Single<String>

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


Example

let rxRequest: Single<Response>

success-obj

rxRequest.fetchString(path: "retBody>name")
    .subscribe(onSuccess: { str in
        print("name -- \(str)")
    }).disposed(by: disposeBag)

// name -- MoyaMapper

success-array

rxRequest.fetchString(path: "retBody", keys: [1, "github"])
    .subscribe(onSuccess: { str in
        print("github -- \(str)")
    }).disposed(by: disposeBag)

// github -- https://github.com/LinXunFeng/RxSwiftDemo