JSON parsing using NSJSONSerialization in iOS

后端 未结 6 1186
孤街浪徒
孤街浪徒 2020-12-05 16:36

I am parsing a JSON in my code. But I am getting some unexpected issues while retrieving data of parsed JSON. So let me explain my problem.

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 17:23

    1)Sequence of keys (or nodes) (MESSAGE, RESPONSE and STATUS) is changed as compared to web response above.

    The NSLog of NSDictionary is based on the sorted keys.

    2)The RESPONSE is get enclosed in '(' & ')' braces.

    RESPONSE =(
                {
            email = "abc@gmail.com";
            id = 20;
            location = "31.000,71.000";
            phone = 1234567890;
            username = john;
        }
    );
    

    The RESPONSE is a key and the value is an NSArray. The array contains one NSDictionary object with keys as email, id, location, phone and username.

    NOTE: () says array. {} says dictionary.

提交回复
热议问题