2016-02-26 123 views
-4

我怎样才能从JSON对象从一个先前传递的ID参数从一个ViewController填充一些UILabels?我得到服务器的响应,但是,我不知道如何将键/值对填充到UILabel。JSON对象数据到UILabel

JSON响应我得到的是:

{ 
    product =  { 
     attributes =   (
     ); 
     "average_rating" = "0.00"; 
     backordered = 0; 
     "backorders_allowed" = 0; 
     "button_text" = ""; 
     "catalog_visibility" = visible; 
     categories =   (
     ); 
     "created_at" = "2016-02-23T05:00:55Z"; 
     "cross_sell_ids" =   (
     ); 
     description = "<p>Microsoft Office</p>\n"; 
     dimensions =   { 
      height = ""; 
      length = ""; 
      unit = in; 
      width = ""; 
     }; 
     "download_expiry" = 0; 
     "download_limit" = 0; 
     "download_type" = ""; 
     downloadable = 0; 
     downloads =   (
     ); 
     featured = 0; 
     "featured_src" = "https://qashop.taxometry.com/wordpressv4/wp-content/uploads/2016/02/softwarecontract-150x150.jpg"; 
     "grouped_products" =   (
     ); 
     id = 15; 
     images =   (
         { 
       alt = ""; 
       "created_at" = "2016-02-23T05:01:35Z"; 
       id = 16; 
       position = 0; 
       src = "https://qashop.taxometry.com/wordpressv4/wp-content/uploads/2016/02/softwarecontract-150x150.jpg"; 
       title = "softwarecontract-150&#215;150"; 
       "updated_at" = "2016-02-23T05:01:35Z"; 
      } 
     ); 
     "in_stock" = 1; 
     "managing_stock" = 0; 
     "menu_order" = 0; 
     "on_sale" = 1; 
     parent =   (
     ); 
     "parent_id" = 0; 
     permalink = "https://qashop.taxometry.com/wordpressv4/product/software-contract/"; 
     price = 25; 
     "price_html" = "<del><span class=\"amount\">&#36;30.00</span></del> <ins><span class=\"amount\">&#36;25.00</span></ins>"; 
     "product_url" = ""; 
     "purchase_note" = ""; 
     purchaseable = 1; 
     "rating_count" = 0; 
     "regular_price" = 30; 
     "related_ids" =   (
     ); 
     "reviews_allowed" = 1; 
     "sale_price" = 25; 
     "shipping_class" = ""; 
     "shipping_class_id" = "<null>"; 
     "shipping_required" = 1; 
     "shipping_taxable" = 1; 
     "short_description" = ""; 
     sku = 2370; 
     "sold_individually" = 0; 
     status = publish; 
     "stock_quantity" = "<null>"; 
     tags =   (
     ); 
     "tax_class" = ""; 
     "tax_status" = taxable; 
     taxable = 1; 
     title = "Software Contract"; 
     "total_sales" = 5; 
     type = simple; 
     "updated_at" = "2016-02-23T05:01:41Z"; 
     "upsell_ids" =   (
     ); 
     variations =   (
     ); 
     virtual = 0; 
     visible = 1; 
     weight = "<null>"; 
    }; 
} 
+0

你为什么不谷歌和从头开始?将响应存储在NSDictionary中并使用它! – Hima

+1

您想要将什么值填充到您的标签? – iPeter

+0

谷歌如何把json放入一个NSDictionary,然后谷歌如何从一个特定的键NSDictionary得到一个值。将其分配给您的标签。如果你想要确切的答案,然后告诉我们一些代码或告诉我们你需要你的价值的确切关键。 –

回答