【发布时间】:2012-06-15 09:39:37
【问题描述】:
我正在使用 JSON 解析,我将数据放入名为 JSON Array 的数组中。在控制台中看起来像
JSON Array=(
{
"created_by" = 42;
"created_on" = "2012-02-29 11:23:37";
"file_description" = "";
"file_is_downloadable" = 0;
"file_is_forSale" = 0;
"file_is_product_image" = 1;
"file_meta" = "";
"file_mimetype" = "image/jpeg";
"file_params" = "";
"file_title" = "hand shovel";
"file_type" = product;
"file_url" = "images/stories/virtuemart/product/cca3cd5db813ee6badf6a3598832f2fc.jpg";
"file_url_thumb" = "images/stories/virtuemart/product/resized/cca3cd5db813ee6badf6a3598832f2fc_90x90.jpg";
"locked_by" = 0;
"locked_on" = "0000-00-00 00:00:00";
"modified_by" = 42;
"modified_on" = "2012-02-29 11:23:37";
ordering = 0;
"product_name" = "Hand Shovel";
published = 0;
shared = 0;
"virtuemart_category_id" = 1;
"virtuemart_media_id" = 13;
"virtuemart_product_id" = 1;
"virtuemart_vendor_id" = 1;
},
{
"created_by" = 42;
"created_on" = "2012-02-29 11:35:09";
"file_description" = "";
"file_is_downloadable" = 0;
"file_is_forSale" = 0;
"file_is_product_image" = 1;
"file_meta" = "";
"file_mimetype" = "image/jpeg";
"file_params" = "";
"file_title" = "our ladder";
"file_type" = product;
"file_url" = "images/stories/virtuemart/product/8cb8d644ef299639b7eab25829d13dbc.jpg";
"file_url_thumb" = "images/stories/virtuemart/product/resized/8cb8d644ef299639b7eab25829d13dbc_90x90.jpg";
"locked_by" = 0;
"locked_on" = "0000-00-00 00:00:00";
"modified_by" = 42;
"modified_on" = "2012-02-29 11:35:09";
ordering = 0;
"product_name" = Ladder;
published = 0;
shared = 0;
"virtuemart_category_id" = 3;
"virtuemart_media_id" = 8;
"virtuemart_product_id" = 2;
"virtuemart_vendor_id" = 1;
},
现在我需要选择“file_url_thumb”,它实际上是单独数组中的图像。 请让我知道我该怎么做?
【问题讨论】:
-
你试过什么?展示您用于解析 JSON 和提取数据的代码,并说明您尝试过的内容以及它以何种方式不起作用。我们不是来为您编写代码的。
-
[json objectForKey:@"file_url_thumb"];
-
我们还可以看到它们是两个组,其中存在单独的“virtuemart_category_id”,具体取决于该 ID 我如何将完整的组内容放入其他数组中
-
@NickBull 实际上首先我需要根据“virtuemart_category_id”将这两组分成两个数组,因为我正在使用文本字段。即如果在文本字段中输入 3,组内容“virtuemart_category_id”=3 必须在其他数组中分隔。然后我需要搜索实际上是图像的“file_url_thumb”,以显示在图像视图中
-
我试过这个 for (int i=0; i
标签: iphone objective-c ios ipad xcode4.2