0

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

Jakub Hampl
  • 39,863
  • 10
  • 77
  • 106
Kergad
  • 11
  • 1

3 Answers3

1

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.

Charles
  • 50,943
  • 13
  • 104
  • 142
0

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?

peter
  • 1
0

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

Community
  • 1
  • 1
Tudor
  • 4,137
  • 5
  • 38
  • 54