美文网首页
8.IOS Json list

8.IOS Json list

作者: Jingwei | 来源:发表于2014-04-15 23:17 被阅读242次

    原因:

    这个很奇怪,我不知道别人怎么样,我接收服务器json数据的时候,list组织是"()"组织的,而不是标准的"[]

    但同样的服务器程序,android又是正常的,我很奇怪,但也没办法,只有相对应的解析。

    如:

    2014-04-12 11:12:08.201 Incidentally[902:60b] obj: {
        message = "RECEIVEADDRESS_FIND_SUCCESS";
        object =     (
           {
                area = "\"\"";
                city = zabei;
                isdefault = "<null>";
                moblephone = 22222222222;
                province = shanghai;
                receiveaddid = "RECEIVEADDRESS:b8447f44e2434632925e6b2f68389b91";
                receiveaddress = Abcdefasdfjksdhjfk;
                receivename = sdfsdfsdfsdfsdf;
                reluserid = "USERINFO:7c9cf1dcf69f4765bcc45a84a16efbae";
                remarks = "<null>";
                telphone = "<null>";
            }
    
           {
                area = "\"\"";
                city = zabei;
                isdefault = "<null>";
                moblephone = 1111111111111;
                province = shanghai;
                receiveaddid = "RECEIVEADDRESS:b8447f44e2434632925e6b2f68389b91";
                receiveaddress = Abcdefasdfjksdhjfk;
                receivename = sdfsdfsdfsdfsdf;
                reluserid = "USERINFO:7c9cf1dcf69f4765bcc45a84a16efbae";
                remarks = "<null>";
                telphone = "<null>";
            }
    
        );
        type = success;
    }
    

    解决:

    其实很简单,object中包含了多个对象

    NSArray* array = [data objectForKey:@"object"];
    

    然后遍历一圈,做你想做的事情

    for (NSDictionary* receiveaddress in array)
    {
    
    }
    

    要说的话

    对于一大堆的key/value,反序列化为一个对象,ios可以看看 RMMapper

    相关文章

      网友评论

          本文标题:8.IOS Json list

          本文链接:https://www.haomeiwen.com/subject/ldsltttx.html