How do I convert a JSON String into a GSON Object?

I’m going to develop a webservice and its input should be described in JSON which i want to use in my inner logic as a GSON Object. So whoever uses the webservice will send a request with some infmorations like this:

"glossary": {
    "title": "example glossary",
    "GlossDiv": {
        "title": "S",
        "GlossList": {
            "GlossEntry": {
                "ID": "SGML",
                "SortAs": "SGML",
                "GlossTerm": "Standard Generalized Markup Language",
                "Acronym": "SGML",
                "Abbrev": "ISO 8879:1986",
                "GlossDef": {
                    "para": "A meta-markup language, used to create markup languages such as DocBook.",
                    "GlossSeeAlso": ["GML", "XML"]
                "GlossSee": "markup"

What i need now is something to handle it. Something like the following: (it’s just an example how i imagine the following steps to get it run 😉 )

public class AnyClass{

    public AnyClass(String jsonString){
        GSONObject gobject = new GSONObject(jsonString);
        String title = gobject.getValueOf("title");

Thanks for every help 🙂

Source: json

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.