How can I send an NSArray populated with objects via HTTP POST?

I have a list of products / purchases (consisting of product objects with the name, product_id, etc.) on the side of the iPhone. I want to send this list to the server, where I will compare the list on the server with one of the iphone (to combine the changes made and send the combined list back to iphone).

How can I send my array via HTTP POST to the server? I know that you probably cannot just send the array, you would have to store it in either xml or json, probably. But still, I would like to have some opportunities before I start coding :)

Thanks in advance,

LeWiOn

Edit : Solved :) Thanks for helping the guys!

Answer : http://andyj.be.s79833.gridserver.com/blog/?p=65

+2
source share
1 answer

Json seems to be your best option. Xml is complex and complex to parse. SBJson library works great when serializing an object graph. I already did such a process, but I never tried to send my array to the server, instead I compared the hash both with the server and locally, and downloaded the new version if necessary.

Good luck.

Edit Using the SBJSON library, creating a json representation of an object is done like this:

[myObject JSONRepresentation]

SBJSON library is here here

: Json . , , , proxyForJson , . , , .

+4

All Articles