在Dictionary中保存后,响应字符串值更改为Integer值

时间:2017-04-24 17:49:59

标签: ios objective-c json nsdictionary

我正面临一个问题,我在服务器

的响应字符串之下

服务器响应==

{"status":1,"userId":"501600688052021","mobile":" 916236365"}

但是当我将其保存到Dictionary时,很少有字符串值被转换为Integer。如下所示" userId" val现在是整数,移动值是保留的字符串。

Response dictionary formed is ={
    userId = 501600688052021;
    mobile = " 916236365";
    status = 1;
}

以下是代码

[request setHTTPMethod:@"POST"];
 NSData *data = [paramString dataUsingEncoding:NSUTF8StringEncoding];
   [request setHTTPBody:data];
    NSURLResponse *response;
    NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
     NSString *resSrt = [[NSString alloc]initWithData:responseData encoding:NSASCIIStringEncoding];

    NSLog(@"Server Response ==%@", resSrt);

    if(resSrt.length)
    {

        responseDictionary = [NSJSONSerialization JSONObjectWithData:resSrt options:0 error:&err];

        NSLog(@"Response dictionary formed is =%@", responseDictionary);
    }

0 个答案:

没有答案