I am creating an application where a user can create a document and upload it on the network. A bit like pages and Icloud. The user can add images, text fields and in the future videos, all are added in an NsMutableArray By know I am taking a screenshot of the page programmly and uploading it on dropbox, then dydplaying it in a UITableView. It works fine, but itis a screenshot, so you cant scroll the text and see the videos.
For this I decided to use json. I integrated the library correctly, but I am very confused. I can not understand how it works. Do I need to uploadall the pieces separately and then create an json file with the image position and size to put everything to gether in the tableview, or actually convert the image to json language? How can I create a json file and add objects? What is the difference between a json writer, serialization, and parser?
But the thing that confuses me the most is, do i need to convert all the data json language? Then how can I proceed. I need a clear mind plan! Thanks!!
JSON is simply a way of representing data in a simple text based form, much like simple XML does. The most common way to represent binary data (like an image) would be to base 64 encode the data so it becomes an ascii string, and embed that in your JSON data.
Writer: Take a data structure, NSDictionary, NSArray, YourObject etc. and convert it to it’s JSON representation.
Serialization: Convert the JSON representation to something that can be sent across the wire
Parser: Read and parse a JSON data structure, like any other parser, the output can be a number of things such as a DOM tree, a series of events, or a mapping to some native Object.
As for how you need to send/receive data in your application, that is difficult to say, you might want to make small asynchronous calls to retrieve small bits of data and assemble them piece by piece, or receive an entire “page” in a single document. These are more of design decisions about how your application behave. JSON is simply the means by which you’ll convert your native objects into some text based format, send them across the wire, and re-assemble them into native objects once again.
There are numerous good basic JSON tutorials online, a google search will turn up a number of good beginner tutorials.