[英]how to parse with double quotes array of dictionary into json in ios?
How to add double quotes for numbers. 如何为数字添加双引号。 When I am parsing, for numbers not coming double quotes.
当我解析时,数字不能用双引号引起来。 For strings double quotes are coming fine.
对于字符串,双引号会很好。 I want double quotes for all.
我想要所有的双引号。 Below is my array of dictionary
下面是我的字典数组
This array of dictionary I was created 我创建的这个字典数组
(
{
questionId = 91;
responseLanguage = ar;
responseType = 4;
},
{
questionId = 92;
responseLanguage = ar;
responseType = 2;
}
)
I want to parse like this 我想这样解析
[{"questionId":"91","responseType":"4","responseLanguage":"ar"}, {"questionId":"92","responseType":"2","responseLanguage":"ar"}]
when am parsing using sbjson parser only strings it was coming double quotes, for numbers it was not coming double quotes. 当使用sbjson解析器仅对字符串进行解析时,它使用双引号,对于数字则不使用双引号。
(
{
questionId = @"91";
responseLanguage = ar;
responseType = @"4";
},
{
questionId = @"92";
responseLanguage = ar;
responseType = @"2";
}
)
This will do and if this array is generating dynamic then convert number into string using "stringValue" method when to add into dictionary 它将执行此操作,并且如果此数组生成动态数组,则在添加到字典时使用“ stringValue”方法将数字转换为字符串
NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:
[nsnumber stringValue], @"questionId",
ar, @"responseLanguage",
[nsnumber stringValue], @"responseType", nil];
While creating dictionary convert the numbers to strings. 创建字典时,将数字转换为字符串。 Double quotes represents the strings.
双引号代表字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.