将NSString转换为NSDictionary - jsonserialization error 3840

时间:2017-06-09 14:28:01

标签: objective-c nsstring nsdictionary nsjsonserialization

我在说明中有一个字符串,后面给出了输出 - @"{\n \"40147089-db8b-4223-89ab-7a2f72ac57d6\" = {\n \"22337b85-d2cf-4079-8d5f-9804cb680f2c\" = (\n yes\n );\n \"87eeb49f-b34a-431b-8701-bd7f36bc91ea\" = (\n yes\n );\n };\n \"7262d43c-4d72-4e71-9097-6db5632d1f54\" = {\n \"22337b85-d2cf-4079-8d5f-9804cb680f2c\" = (\n yes\n );\n \"58ecb861-4372-412b-8740-a9f94260ed93\" = (\n yes\n );\n };\n}"

如何将其转换为NSDictionary?永远jsonserialisation扔我错误域= NSCocoaErrorDomain代码= 3840“字符45周围的对象键没有值。”

这就是我在打印ResponseObj时得到的,其中ResponseObj的类型为id

po responseObject

{
"159476cc-3e1f-4995-bf23-df41141dd8c5" = 2;
"6280ecfe-841e-4a35-8002-3e9e7327ba7d" = 2;
"64de3fc6-ff59-4e91-a2e7-f3ec904eecce" =     {
    "40147089-db8b-4223-89ab-7a2f72ac57d6" =         {
        "22337b85-d2cf-4079-8d5f-9804cb680f2c" =             (
            yes
        );
        "87eeb49f-b34a-431b-8701-bd7f36bc91ea" =             (
            yes
        );
    };
    "7262d43c-4d72-4e71-9097-6db5632d1f54" =         {
        "22337b85-d2cf-4079-8d5f-9804cb680f2c" =             (
            yes
        );
        "58ecb861-4372-412b-8740-a9f94260ed93" =             (
            yes
        );
    };
};
"83ec5c05-cb2f-4c49-b9a3-ab44c487bf55" =     {
    "2a8dd370-2f7e-4c8e-93d5-21102fbc82fd" =         {
        "957bdaba-b23d-4243-8384-62dfa46f0656" = work;
    };
    "b3e0aded-d57b-4159-9c33-c8b006282334" =         {
        "aba16653-bda0-4e89-b1c8-63df6faa7c10" =             (
            yes
        );
    };
    "d765038e-e85a-495d-9932-170852fbd86e" =         {
        "57646099-b717-4a2b-b9eb-2935548ae954" =             (
            yes
        );
        "957bdaba-b23d-4243-8384-62dfa46f0656" = play;
    };
};
"c81e7d71-6f1e-4b83-8740-c73ee52e3b0b" =     (
    2
);
}

1 个答案:

答案 0 :(得分:1)

请使用NSJSONSerialization获取数据。