HANDLING JSON IN ANDROID

JAMES Williams

Total Post:7

Points:49
Posted by  JAMES Williams
 774  View(s)
Ratings:
Rate this:
I am working on  an android application, I would like to send messages in the form of JSON objects to a Django Server and parse the JSON response from the server and populate a custom listview.

From the little JSON knowledge I have, I thought this format for the response from server
{
  "post": {
    "username": "someusername",
    "message": "this is a sweet message",
    "image": "http://localhost/someimage.jpg",
    "time":  "present time"
  },
}
  1. Mayank Tripathi

    Post:397

    Points:3117
    Re: Handling JSON in Android

    Use GSon and Jackson :


    We can actually bind to our own POJOs, not some half-assed tree nodes or Lists and Maps. (and at least Jackson allows binding to such things too (perhaps GSON as well, not sure), JsonNode, Map, List, if you really want these instead of 'real' objects)
    Jackson.jr uses same fast Streaming parser/generator as Jackson (jackson-core), but data-binding part is tiny (50kB). Functionality is more limited (no annotations, just regular Java Beans), but performance-wise should be fast, and initialization (first-call) overhead very low as well. So it just might be good choice, especially for smaller apps.

    You can use org.json.JSONObject  and org.json.JSONTokener you don't need any external libraries since these classes come with Android SDK



Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!