我有一本需要轉換爲Json的字典詞典。將嵌套字典轉換爲json swift
[
Dict1:1,
test: A Value,
NestedDict1:[
city: A City Name,
address: An Address,
NestedDict2: [
1: 1,
39: 2
],
favorite1: 2,
favorite3: Chocolate
]
]
當我使用
NSJSONSerialization.dataWithJSONObject(myJsonDict, options: NSJSONWritingOptions.PrettyPrinted, error: nil)
僅編碼最外面的字典。所以我的輸出如下所示:
{
"Dict1":"1",
"test": "A Value",
"NestedDict1":"[
city: A City Name,
address: An Address,
NestedDict2: [
1: 1,
39: 2
],
favorite1: 2,
favorite3: Chocolate
]"
}
我該如何JSON內部字典呢?
儘量不要通過'.PrettyPrinted'爲'選項:「論點? – nhgrif
http://stackoverflow.com/questions/8356842/how-to-use-nsjsonserialization – kbgn
爲什麼有人投票呢?看起來對我來說是一個非常有效的問題! – Icaro