EKet
EKet

Reputation: 7314

iPhone parse JSON on phone or on server?

I'm not sure if this is even possible on the iphone.

Scenario 1:

I get some json object by calling some api through a URL. I parse the json on my iphone and display results.

OR

Scenario 2
But let's say I get some json object by calling some api through URL. I pass the object to a web service to parse it with C# and return the data organized the way I want then parse it again (but obviously nicer and cleaner parsing)

Which one do you think is better if both are possible?!

Thanks

Upvotes: 0

Views: 355

Answers (3)

Domestic Cat
Domestic Cat

Reputation: 1434

Parsing JSON on the iPhone is very easy. I suggest using SBJSON (https://code.google.com/p/json-framework/downloads/list), it will parse the JSON in objects for you.

Here is a tutorial: http://iosdevelopertips.com/cocoa/json-framework-for-iphone-part-2.html

Upvotes: 1

hotpaw2
hotpaw2

Reputation: 70673

Depends on the size of the JSON objects and the amount you need to download.

Apple mentioned, on one of their WWDC 2010 videos, that for large list downloads, using compressed plist formatted data is more efficient overall, in terms of total battery consumption, than JSON or XML. But for small and infrequent downloads, the difference is probably negligible, and not transcoding JSON will result is far less total system complexity.

Upvotes: 1

Mitch Lindgren
Mitch Lindgren

Reputation: 2160

#1 is definitely better. Why would you parse the JSON with C# only to put it in a different format and then re-parse it? That seems needlessly inefficient.

Upvotes: 1

Related Questions