简体   繁体   中英

iPhone- Send JSON Object to PHP server in POST

I would like to send my contact list with all numbers for each numbers.

I'm trying 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.

Eg 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM