如何解析这些数据

时间:2013-05-06 06:13:46

标签: iphone ios afnetworking

我是iphone的新手,无法理解如何解析这些数据,以便我将在表格视图中显示结果。当我调用megento的api时,以下数据是AFHTTPRequestOperation的结果。

{
        "callforprice_id" = 13;
        country = Austria;
        "created_time" = "2013-05-03 12:03:05";
        emailid = "indies.tester@gmail.com";
        message = hfhftrfygjh;
        name = "Richard Conover";
        "phone_no" = 8977896;
        "product_name" = Ottoman;
        "product_options" = "";
        "update_time" = "0000-00-00 00:00:00";
    },
        {
        "callforprice_id" = 12;
        country = "Antigua and Barbuda";
        "created_time" = "2013-05-03 12:01:24";
        emailid = "indies.tester@gmail.com";
        message = sdfsdfsdfwe;
        name = "Richard Conover";
        "phone_no" = 5645;
        "product_name" = Ottoman;
        "product_options" = "";
        "update_time" = "0000-00-00 00:00:00";
    },
        {
        "callforprice_id" = 11;
        country = Angola;
        "created_time" = "2013-05-03 11:58:51";
        emailid = "indies.tester@gmail.com";
        message = 6tyrtyryrty;
        name = "Kaitlyn Matheson";
        "phone_no" = 564564;
        "product_name" = Ottoman;
        "product_options" = "";
        "update_time" = "0000-00-00 00:00:00";
    }

3 个答案:

答案 0 :(得分:1)

如果你想在UITableview中显示数据然后使用这个,那就试试这个。,

NSString *str=[[resultArray objectAtIndex:indexPath.row] valueForKey:@"country"];

(OR)

获取字典

等数据
for(NSDictionary *dict in resultArray){
        NSString *str=[dict valueForKey:@"country"];

    }

答案 1 :(得分:1)

http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_afnetworking/

检查上面的链接,按照一步一步的流程进行。

希望对你有所帮助

答案 2 :(得分:1)

  1. 完全在NSArray * jsonDataArray中完成。
  2. 在TableView中,numberOfRowsInSection使用return [jsonDataArray Count];
  3. 在tableview中,SelectRowAtIndexPath取一个NSDictionary * dictionary =(NSDictionary *)[jsonDataArray objectAtIndex:indexPath.row];在这本词典中,你将分别得到每个对象
  4. 然后你可以通过[dictionary objectForKey:@“attribute_name”]访问任何元素;