I'm starting to develop an application for Google Android and heavily relying on a web API that can deliver data in a restful way via json or xml. I now have to decide which library to choose.
I saw that google includes org.json classes in the API but haven't tested them yet.
How are your experiences? What library/API should I use and why?
JSON is best for simple applications, developed to satisfy simple requirements surrounding data interchange. XML is best for applications with complex requirements surrounding data interchange, such as in enterprise.
One of the most significant advantages of using JSON is that the file size is smaller; thus, transferring data is faster than XML. Moreover, since JSON is compact and very easy to read, the files look cleaner and more organized without empty tags and data.
Android JSONObject is used for JSON parsing in android apps. In this tutorial we'll discuss and implement a JSONObject in our android application to parse JSON data. JSON stands for JavaScript Object Notation.
If you're mostly aiming for an internal API that is simply a link between servers you control and a client you're creating, I'd highly recommend JSON - it's far more concise in most cases, thus minimizing the data transfer necessary.
Parsing JSON with org.json is as straightforward as passing the JSON string to the constructor of JSONObject, and then using the appropriate type get-methods on each of your expected attributes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With