Friday 15 January 2010

JSON format and objective-c -


My app needs to submit a Jason payload on the server, the server wants the format itself:

  {"recipient_emails": ["test@xyz.net", "user@xyz.com"]}   

All I think is this format: < / P>

  {"recipient_emails" = ("test@xyz.net", "user@xyz.com"); }   

What I am submitting does not work, which I can not tell whether it is a server problem on our server or I am submitting JSON's format.

Here's how I create JS:

  // Get the data (from NSManagedObject) NSString * emailData = [[NSString alloc] initWithData: self.submissionRecipients encoding: NSUTF8StringEncoding ]; // Remove all different email addresses NSArray * Email = [Email Data Components: Separated Byteering: @ ","]; // If there are some (which should always be) if (email) {NSError * error; // Add the array for an NSDictionary with the key and change the JSON NSData * jsonData = [NSJSONSerialization data with the GigSession object: [Object with NSDictionary: For email: @ "Recipient_mail"] Option: 0 error: and error]; // json HTTPRequest [theRequest setHTTPBody: jsonData]; // Print for debug purposes NSDictionary * Dyke = [NSJSNSRailization JSONObjectWithData: jsonData option: kNilOptions error: zero]; NSLog (@ "% @", DIC); The description of    

NSArray - uses the bracket ' If you use NSJSONSerialization , do not worry, the derivative JSON will contain properly square brackets.

No comments:

Post a Comment