I’m familiar with iOS/Xcode development and now trying to develop my own web services. Unfortunately I’m struggling with the best way to pass a JSON string from my iOS application to the PHP page.
In xcode I create a JSON string similar to:
{"email" : "", "name" : "Test Rest",}
I’m then creating a URL (GET) :
//localhost/index.php?method=createRestaurant&json={"email" : "", "name" : "Test Rest",}
I’m trying to use NetBeans to debug the PHP but both NetBeans & iOS fail with either bad URL or invalid character error, and from what I’m guessing it’s the JSON characters that are failing {}.
If I use Chrome PostMan and issue the same URL it works which proves that the PHP is work / doing what I need it to do.
So in summary what is the best way to include the JSON data in the URL is the something that needs changing in XCode that affects the way the JSON is encoded?
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:myDictionary options:NSJSONWritingPrettyPrinted error:&error];
jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
In an ideal world I should be using Java but due to speed, environment costs etc I’m attempting to get my system working using PHP. Once the solution is complete I’ll then work on porting the solution to Java.
Thanks for any help.