I would like to send my contact list with all numbers for each numbers.
I'm tr开发者_JAVA百科ying to send a JSON Object (with all my data) to a PHP file and to decode with the json_decode
function.
Is it possible to use JSON to send to a server by POST in HTTPrequest
Is it possible to use JSON to send to a server by POST in HTTPrequest
JSON is just text. You can send text via POST, right? Then you can send JSON.
You can use JSON.stringify to create a String from a JavaScript Object.
E.g. JSON.stringify({field1:"a", field2:"b"})
I would use any library like jQuery to post JSON data to the server.
Does that answer your question?
First of all, as @Charles said, JSON is a string. As long as it's part of a POST which you can retrieve on your server, it should be enough.
ASIHTTPRequest is a great library for handling POST data sent from the iPhone to your server. Here's an example on how to send a POST: http://allseeing-i.com/ASIHTTPRequest/How-to-use#sending_a_form_post_with_ASIFormDataRequest
Here's a question related to encoding a NSString to JSON: Send NSMutableArray as JSON using JSON-Framework
精彩评论