簡體   English   中英

如何將字典的雙引號數組解析為ios中的json?

[英]how to parse with double quotes array of dictionary into json in ios?

如何為數字添加雙引號。 當我解析時,數字不能用雙引號引起來。 對於字符串,雙引號會很好。 我想要所有的雙引號。 下面是我的字典數組

我創建的這個字典數組

    (
    {
    questionId = 91;
    responseLanguage = ar;
    responseType = 4;
},
    {
    questionId = 92;
    responseLanguage = ar;
    responseType = 2;
}
)

我想這樣解析

[{"questionId":"91","responseType":"4","responseLanguage":"ar"},  {"questionId":"92","responseType":"2","responseLanguage":"ar"}]

當使用sbjson解析器僅對字符串進行解析時,它使用雙引號,對於數字則不使用雙引號。

(
  {
    questionId = @"91";
    responseLanguage = ar;
    responseType = @"4";
  },
  {
    questionId = @"92";
    responseLanguage = ar;
    responseType = @"2";
  }
)

它將執行此操作,並且如果此數組生成動態數組,則在添加到字典時使用“ stringValue”方法將數字轉換為字符串

NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:
                                [nsnumber stringValue], @"questionId",
                                ar, @"responseLanguage",
                                [nsnumber stringValue], @"responseType", nil];

創建字典時,將數字轉換為字符串。 雙引號代表字符串。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM