First of all thanks for the help guys in advance. I have found this forum to be of great help with getting the issues resolved that I am having coming from Android / HTML to IPhone / XCODE programming even if it is just pointing me in the right direction.
I have noticed something weird with the JSON parsing format. Half of the variables have quotes around them and the other half do not. They all have parenthesis around them as well.
Here is my json parsing code in the .m file
and the results are
If I can get rid of the parenthesis and the quotes it would make me a lot happier. It converts half my JSON data string that way and I can't figure out what its doing.
Thanks for all the help guys
John
I have noticed something weird with the JSON parsing format. Half of the variables have quotes around them and the other half do not. They all have parenthesis around them as well.
Here is my json parsing code in the .m file
Code:
NSString *strURL = [NSString stringWithFormat:@"http://10.4.4.11/ticket4/android5.php?Fone=%@&pincode=%@&confirm=%@&edit=Register", PhoneText, PinText,ConfirmText ];
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString : strURL]];
NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
NSData * datajson = [strResult dataUsingEncoding: NSUTF8StringEncoding];
id my2ConvertedJSONData = [NSJSONSerialization JSONObjectWithData : datajson options: NSJSONReadingMutableContainers error:&localError];
if ([my2ConvertedJSONData isKindOfClass:[NSDictionary class]]) {
NSLog(@"DICTIONARY");
NSLog(@"dict3: %@", my2ConvertedJSONData);
}
if ([my2ConvertedJSONData isKindOfClass:[NSArray class]])
{
NSArray * anArray = my2ConvertedJSONData;
NSLog(@"ARRAY count: %i", [anArray count]);
if ([[anArray objectAtIndex: 0] isKindOfClass:[NSDictionary class]]) NSLog(@"Yep, dictionary inside of an array!");
NSLog(@"Array dict index 0: %@", [anArray objectAtIndex: 0]);
location = [my2ConvertedJSONData valueForKey:(NSString *)@"location"];
firstname = [my2ConvertedJSONData valueForKey:@"firstname"];
Code:
2012-06-11 22:27:58.867 tickets25[4846:f803] firstname = (
John
)
and
2012-06-11 22:27:58.870 tickets25[4846:f803] location = (
"Las Vegas, NV"
)
If I can get rid of the parenthesis and the quotes it would make me a lot happier. It converts half my JSON data string that way and I can't figure out what its doing.
Thanks for all the help guys
John