私は私のNSDictionary
はそのようなものです ....次のような問題に苦しんでいます:Swift(iOS、Xcode)でNSDictionaryをJson Stringに変換するには?
var dic : NSDictionary = [ "level" :
[
["column" : 0,"down" : 0,"left" : 0,"right" : 0,"row" : 0,"up" : 0],
["column" : 1,"down" : 0,"left" : 0,"right" : 0,"row" : 0,"up" : 0],
["column" : 2,"down" : 0,"left" : 0,"right" : 0,"row" : 0,"up" : 0],
["column" : 0,"down" : 0,"left" : 0,"right" : 0,"row" : 1,"up" : 0],
["column" : 1,"down" : 0,"left" : 0,"right" : 0,"row" : 1,"up" : 0],
["column" : 2,"down" : 0,"left" : 0,"right" : 0,"row" : 1,"up" : 0]
]
]
しかし、私はこれを印刷する場合、
print(dic); or print(“\(dic)”);
アウトプットは、そのようなものです:
{
level = (
{
column = 0;
down = 0;
left = 0;
right = 0;
row = 0;
up = 0;
},
{
column = 1;
down = 0;
left = 0;
right = 0;
row = 0;
up = 0;
},
{
column = 2;
down = 0;
left = 0;
right = 0;
row = 0;
up = 0;
},
{
column = 0;
down = 0;
left = 0;
right = 0;
row = 1;
up = 0;
},
{
column = 1;
down = 0;
left = 0;
right = 0;
row = 1;
up = 0;
},
{
column = 2;
down = 0;
left = 0;
right = 0;
row = 1;
up = 0;
}
); }
どのように正確なJson Stringを取得できますか? 速く、xcodeで?
簡単な解決策確認してください:http://stackoverflow.com/a/29628000/3378413 –