Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何在iPhone中以JSON格式从数组中逐个提取值? 数组 达塔( ( { Description=“_Objective C_Iphone_Json - Fatal编程技术网

Objective c 如何在iPhone中以JSON格式从数组中逐个提取值? 数组 达塔( ( { Description=“

Objective c 如何在iPhone中以JSON格式从数组中逐个提取值? 数组 达塔( ( { Description=“,objective-c,iphone,json,Objective C,Iphone,Json,Image3”; “图像标识”=68; “Image_Path”=“aa6b74d47227ebd24561211a2c95199c.jpg”; “产品地址”=“拉贾斯坦邦斋浦尔”; “已预订产品”=N; “产品标识”=1; “产品信息”=“印度酒店有限公司(IHCL)其子公司统称为泰姬陵酒店、度假村和宫殿,被公认为亚洲最大、最好的酒店公司之一。由塔塔集团创始人Jamsetji N.Tata先生注册成立,该公司于1903年在孟买开设了其第一家酒店,即泰姬陵皇宫酒店。泰姬陵是印度好客的象征2003

Image3

”; “图像标识”=68; “Image_Path”=“aa6b74d47227ebd24561211a2c95199c.jpg”; “产品地址”=“拉贾斯坦邦斋浦尔”; “已预订产品”=N; “产品标识”=1; “产品信息”=“印度酒店有限公司(IHCL)其子公司统称为泰姬陵酒店、度假村和宫殿,被公认为亚洲最大、最好的酒店公司之一。由塔塔集团创始人Jamsetji N.Tata先生注册成立,该公司于1903年在孟买开设了其第一家酒店,即泰姬陵皇宫酒店。泰姬陵是印度好客的象征2003年是它的百年诞辰。”; “产品纬度”=“26.9260\U00b0N”; “产品长度”=“75.8235\U00b0E”; “产品名称”=demo1; “产品报价”=“200美元”; “产品价格”=“$345”; “产品类型”=“五星”; }, { Description=“yo

”; “图像_Id”=75; “图像路径”=“415e2e6b7a3b1850e06467ade2e10fa9.jpg”; “产品地址”=“拉贾斯坦邦斋浦尔”; “已预订产品”=N; “产品标识”=2; “产品信息”=“五星”; “产品纬度”=“”; “产品长度”=”; “产品名称”=“酒店夜车”; “产品报价”=“200美元”; “产品价格”=“$345”; “产品类型”=“五星”; } ) ) 签出并使用它解析json字符串。

NSString*responseString=[request1 responseString]//您的json响应将出现在这里
Array 

DAATA (
            (
                    {
                Description = "<p>Image3</p>";
                "Image_Id" = 68;
                "Image_Path" = "aa6b74d47227ebd24561211a2c95199c.jpg";
                "Product_Address" = "Jaipur ,Rajastha";
                "Product_Booked" = N;
                "Product_Id" = 1;
                "Product_Info" = "The Indian Hotels Company Limited (IHCL) and its subsidiaries are collectively known as Taj Hotels Resorts and Palaces and is recognised as one of Asia's largest and finest hotel company. Incorporated by the founder of the Tata Group, Mr. Jamsetji N. Tata, the company opened its first property, The Taj Mahal Palace Hotel, Bombay in 1903. The Taj, a symbol of Indian hospitality, completed its centenary year in 2003. ";
                "Product_Latitude" = "26.9260\U00b0N";
                "Product_Longitute" = "75.8235\U00b0E";
                "Product_Name" = demo1;
                "Product_Offer_Price" = "$200";
                "Product_Price" = "$345";
                "Product_Type" = "five star";
            },
                    {
                Description = "<p>yo yo</p>";
                "Image_Id" = 75;
                "Image_Path" = "415e2e6b7a3b1850e06467ade2e10fa9.jpg";
                "Product_Address" = "jaipur,rajasthan";
                "Product_Booked" = N;
                "Product_Id" = 2;
                "Product_Info" = "five star";
                "Product_Latitude" = "";
                "Product_Longitute" = "";
                "Product_Name" = "hotel night rider";
                "Product_Offer_Price" = "$200";
                "Product_Price" = "$345";
                "Product_Type" = "five star";
            }
        )
    )
NSMutableDictionary*dataDict=[[responseString JSONValue]valueForKey:@“DAATA”]mutableCopy]//用言语回应
对于(inti=0;i另一种选择是使用库


首先写你的代码…然后我建议你。!!检查我的答案,你的值似乎已经被提取,否则你怎么能发布它们。。。?
 NSString *responseString = [request1 responseString];//your json response will be here
 NSMutableDictinoary *dataDict = [[[responseString JSONValue] valueForKey:@"DAATA"]mutableCopy];//take response in dictinoary
 for(int i = 0 ; i<[[dataDict valueForKey:@"DAATA"] count];i++)
{
    if([[[[dataDict valueForKey:@"DAATA"] objectAtIndex:i] valueForKey:@"Image_Id"] isEqualToString:@"court"])//get what you want here for example get "Image_Id"
    {
        NSMutableDictionary *dd=[[dataDict valueForKey:@"result"] objectAtIndex:i];
        [arrCourt addObject:dd];
    }
   and so on.........

}
- (void) connectionDidFinishLoading:(NSURLConnection *) conn 
{
//Call back called when data reception completes (stored in variable data)
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSDictionary *results = [jsonString JSONValue]; // This is a new category added to the NSString by SBJSON
if ([results count]>0)
{ 
    // decoding a JSON object like so: {"result":"yes"}
    [results objectForKey:@"result"] ;
    if ([[results objectForKey:@"result"] isEqualToString:@"yes"])
    {
        [self registrationStateSetTo:YES];
        NSLog(@" registered OK "); 
    }
    else 
    {
        [self registrationStateSetTo:NO];
        NSLog(@" registration failed "); 
    }
}
}