我有數組裏面存儲的JSON values.when我試着給這個值字典給定的錯誤。如何從數組中提供json值到字典?
arrhole{
"cust_groups" = "";
"customer_id" = 1;
"customer_name " = "";
"date_added" = "<null>";
"delivery_method" = "";
fname = kishore;
gift = "";
lname = kumar;
message = "";
month = "";
"order_id" = 1;
"pay_method" = "";
"payment_firstname" = "";
"payment_lastname" = "";
phone = 9043563659;
region = "";
reward = "";
"scheduled_date" = "28/08/2015";
"sen_email" = "";
"sen_name" = "";
"shipping_city" = "";
"shipping_company" = "";
"shipping_country" = IND;
"shipping_region" = 1503;
"unit_price" = 22;
voucher = "";
}
此代碼我已經使用:
-(void)responseFunction:(NSMutableDictionary *)response
{
NSLog(@"response method%@",response);
BOOL success;
success =[[response objectForKey:@"success"] boolValue];
arrHoleOrderDetails =[response objectForKey:@"order"];
NSLog(@"arrhole%@",arrHoleOrderDetails);
if(success)
{
for (NSDictionary *dic in arrHoleOrderDetails)
{
NSLog(@"dic===%@",dic);
}
}
OUTPUT:
dic===city
dic===shipping_address
dic===shipping_lastname
dic===pay_method
dic===customer_id
dic===country
dic===region
這樣它的顯示在我的log.i顯示這裏只有一些價值。
1.是否爲json響應問題?
2.或者我的愚蠢的錯誤?
完全響應:
order = {
address = "";
address1 = "";
address2 = "";
affliate = "";
amount = "";
city = "";
comment = "";
company = "";
"company_id" = "";
country = "";
coupon = "";
"cust_groups" = "";
"customer_id" = 2;
"customer_name " = "";
"date_added" = "<null>";
"delivery_method" = "";
email = "";
fax = "";
fname = arun;
gift = "";
lname = "";
message = "";
month = "";
"order_id" = 2;
"pay_method" = "";
"payment_firstname" = "";
"payment_lastname" = "";
phone = "";
postcode = "";
product = 4;
quantity = 5;
"rec_email" = "";
"rec_name" = "";
region = "";
reward = "";
"scheduled_date" = "28/08/2015";
"sen_email" = "";
"sen_name" = "";
"shipping_address" = "";
"shipping_address1" = "";
"shipping_address2" = "";
"shipping_city" = "";
"shipping_company" = "";
"shipping_country" = "";
"shipping_firstname" = "";
"shipping_lastname" = "";
"shipping_postcode" = "";
"shipping_region" = "";
status = "";
stores = "";
total = "";
"unit_price" = 540;
voucher = "";
};
success = 1;
}
你到底想要什麼?因爲你有一串字符串 – iPhone
你想如何處理這個arrHoleOrderDetails數組? – iPhone
這是我存儲在數組中的json響應,我需要在標籤中顯示,所以我將值從數組傳遞到字典,但是我提到的輸出如上所示。 –