Convert JSON to HashMap using Gson in Java

Posted by mridang on Stack Overflow See other posts from Stack Overflow or by mridang
Published on 2010-05-06T07:29:34Z Indexed on 2010/05/06 13:18 UTC
Read the original article Hit count: 1201

Filed under:
|
|
|
|

Hi,

I'm requesting data from a server which returns data in the JSON format. Casting a HashMap into JSON when making the request wasn't hard at all but the other way seems to be a little tricky. The JSON response looks like this:

{ "header" : { "alerts" : [ { "AlertID" : "2",
            "TSExpires" : null,
            "Target" : "1",
            "Text" : "woot",
            "Type" : "1"
          },
          { "AlertID" : "3",
            "TSExpires" : null,
            "Target" : "1",
            "Text" : "woot",
            "Type" : "1"
          }
        ],
      "session" : "0bc8d0835f93ac3ebbf11560b2c5be9a"
    },
  "result" : "4be26bc400d3c"
}

What way would be easiest to access this data? I'm using the GSON module.

Cheers.

© Stack Overflow or respective owner

Related posts about java

Related posts about gson