[英]how to convert json object to string format in ios
这是我在输出日志中打印的json格式,我的第一个疑问是我如何在json对象中为mystatus对象创建单独的类,并使用mystatus对象,我需要检查输入的用户名和密码是否正确,如果有效的用户名意味着应该返回值为s
这是我的回应
{"login_response":[{"phone":"000000000","status":"Login Successfull",","**mystatus**":"S","mpin":"",","card_store_flag":"0"}]}
请尝试这个.....
NSData *MyData = [jsonResponce dataUsingEncoding:NSUTF8StringEncoding];
NSError *error;
NSString *strString = [NSJSONSerialization JSONObjectWithData:MyData options:NSJSONReadingMutableContainers error:&error];
NSURL *myURL = [[NSURL alloc]initWithString:@"http://yourwebservice link with json"];
NSData *myData = [[NSData alloc]initWithContentsOfURL:myURL];
if (myData == nil)
{
NSLog(@"NO INTERNET");
}
else
{
NSLog(@"INTERNET EXIST");
NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:myData options:kNilOptions error:nil];
for (id element in jsonArray)
{
NSString *durum = [element objectForKey:@"yourJsonHeader"];
if([yourJsonHeader isEqualToString:@"1"])
{
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.