当小数点添加时,字典上的ios双引号 [英] ios double quotes on dictionary when decimal point added

查看:229
本文介绍了当小数点添加时,字典上的ios双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与JSON交互,因为get它运行正常,

Im interacting with JSON, for "get" it works ok,

但是对于post,我有一个错误,因为字典对象被双重包围引用

But with the "post", I have an error as the dictionary objects are surrounded with double quotes ""

并且对于Web服务,我得到双引号的错误,
问题是如果我用一个点来表示小数然后出现双引号,

and for the web service, i get an error for the double quotes, the problem is that if i use a dot to indicate a decimal point then the double quotes appear,


NSMutableDictionary * dicto = [[NSMutableDictionary alloc] init];

NSMutableDictionary *dicto = [[NSMutableDictionary alloc]init];



[dicto setObject:@"-33.82007932" forKey:@"Latitude"];

[dicto setObject:@"151.1850004" forKey:@"Longitude"];
[dicto setObject:@"10728" forKey:@"TransmissionAreaId"];
[dicto setObject:@"[11278,10747,10728,11503]" forKey:@"OtherTransmissionAreaIds"];

这是日志


2011-10-10 17:28:47.265 MySwitch [14632:707]字典{
Latitude = - 33.820080;
经度=151.1850004;
OtherTransmissionAreaIds =[11278,10747,10728,11503];
TransmissionAreaId = 10728;
}

2011-10-10 17:28:47.265 MySwitch[14632:707] the dictionary { Latitude = "-33.820080"; Longitude = "151.1850004"; OtherTransmissionAreaIds = "[11278,10747,10728,11503]"; TransmissionAreaId = 10728; }

所以 TransmissionAreaId = 10728

似乎没问题,但如果我测试并使用小数点即: TransmissionAreaId = 10728.01

appears ok, but if I test and use a decimal point ie: TransmissionAreaId = 10728.01

然后我得到双引号,

那我怎么能摆脱双引号??

So how can i get rid of the double quotes??

非常感谢!

推荐答案

无论您在 NSLog 中显示什么值,它都是将值显示为字符串。它的性质是 NSLog ,如果它们包含除字母数字值以外的特殊字符,它会在值周围添加双引号()。

Whatever the value you display in NSLog, it displays the value as string. Its a nature of NSLog that it adds double-quotes(") around the values if they contain special characters other than alphanumeric values.

NSLog 在显示数组和字典等对象时执行此操作。因此,当您只打印字符串或浮点值时,您将看不到此行为直接在 NSLog

NSLog does this when it displays objects such as arrays and dictionaries. So, you won't see this behavior when you print just a string or float value directly in NSLog.

并且,与此无关,而不是担心!

And, you have nothing to do with that than stop worrying!

这篇关于当小数点添加时,字典上的ios双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆