Moya: Request Object mapJSON cant' use

Created on 28 Mar 2018  路  2Comments  路  Source: Moya/Moya

when i send a request i got here response:

{
    data =     {
        deviceShareSet =         (
        );
        id = 4028814062666bf90162666c09b10000;
        locations =         (
        );
        password = hehe;
        phone = 17520440116;
        token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ4amtqIiwiZXhwIjoxNTI3NDEyMjY5LCJ1c2VySUQiOiI0MDI4ODE0MDYyNjY2YmY5MDE2MjY2NmMwOWIxMDAwMCJ9.hjfUchx2QQEZ2PrQ-pstwkPELpZ76oQRX7-vGb4CwLk";
        userRelationships =         (
        );
    };
    status =     {
        code = 1;
        haveNext = 0;
        message = "\U767b\U5f55\U6210\U529f";
    };
}

my code:

provider.rx
            .request(.Login(data, message, aesIV.ivCode))
            .mapJSON().subscribe {
                switch $0 {
                case .success(let data):
                    print(data)
                case .error(_):
                    break
                }
            }
        .disposed(by: disposeBag)

i can print the data, but i can' use like this data["data"]

Type 'Any' has no subscript members

then i use like this

let dic = data as! [String: String] 
// let dic = data as! [String: [String: String]]

it will crash

question

Most helpful comment

@BasThomas It works, thanks a lot

All 2 comments

Hey @lSkyPivot, what about let dictionary = data as? [String: Any]?

@BasThomas It works, thanks a lot

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hamada147 picture hamada147  路  3Comments

fenixsolorzano picture fenixsolorzano  路  3Comments

JoeFerrucci picture JoeFerrucci  路  3Comments

ghost picture ghost  路  3Comments

JianweiWangs picture JianweiWangs  路  3Comments