0

How can I generate this JSON acording to RPC 2.0 standard?

{"jsonrpc":"2.0","method":"authenticate","params":{"serviceName":"MyServiceName","serviceKey":"3456789876543234567uyfde6765","user":"xxx.yyyy@gmail.com","password":"KJSksk78SW"}, "id": "3"}

Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
ksprs8
  • 53
  • 2
  • 12

1 Answers1

0

If you're using iOS 5.0, you can use the NSJSONSerialization class to do the work for you.

Here's Apple's documentation for it:

http://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html

Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • Ihave made string from my parameters like this NSString *jsonString = @"{\"jsonrpc\":\"2.0\",\"method\":\"authenticate\",\"params\":{\"serviceName\":\"MyServiceName\",\"serviceKey\":\"3456789876543234567uyfde6765\",\"user\":\"xxx.yyyy@gmail.com\",\"password\":\"KJSksk78SW\"}, \"id\": \"3\"}"; How to post it like JSON to PHP? – ksprs8 Mar 26 '12 at 18:56
  • Don't create a JSON string like that. Let iOS do the work for you. [Here is a related question with some additional example code for you](http://stackoverflow.com/questions/8356842/how-to-use-nsjsonserialization). And [here is another question that shows how to post to PHP from iOS](http://stackoverflow.com/questions/9501238/sending-a-post-from-ios-app-to-php-script-not-working-simple-solution-is-like). Hope this helps you out. – Michael Dautermann Mar 26 '12 at 19:00