Android Json Deserialisation problem using Gson?
<p>hii everybody,</p>

<p>I am using Gson library in android to parse json.</p>

<pre><code>enter code here
</code></pre>

<p><strong>ResponseList .java</strong></p>

<p>package com.hussain.classes;</p>

<p>import java.util.Date;
import java.util.List;</p>

<p>@SuppressWarnings("unused")
public class ResponseList {</p>

<pre><code>private List&lt;ResponseTag&gt; server_list;

    public List&lt;ResponseTag&gt; getResponse() {
    return server_list;
    }
    public void setTrends(List&lt;ResponseTag&gt; response) {
    this.server_list = response;
    }


enter code here
</code></pre>

<p><strong>ResponseTag .java</strong></p>

<p>package com.hussain.classes;</p>

<p>public class ResponseTag {
    private String ServUser;
    private String ServURL;
    private String CustID;</p>

<pre><code>    public String getName() {
    return ServUser;
    }
    public void setName(String ServUser) {
    this.ServUser = ServUser;
    }
    public String getUrl() {
    return ServURL;
    }
    public void setUrl(String ServURL) {
    this.ServURL = ServURL;
    }

    public String getCustID() {
    return CustID;
    }
    public void setCustID(String CustID) {
    this.CustID = CustID;
    }
</code></pre>

<p>}</p>

<p>}</p>

<pre><code>enter code here
</code></pre>

<p><strong>Main.java</strong></p>

<p>package com.hussain.gjson;</p>

<p>import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URI;</p>

<p>import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;</p>

<p>import com.google.gson.Gson;
import com.hussain.classes.ResponseList;
import com.hussain.classes.ResponseTag;</p>

<p>import android.app.Activity;
import android.os.Bundle;
import android.util.Log;</p>

<p>public class Main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);</p>

<pre><code>        try{
        Log.i("MY INFO", "Json Parser started..");


        Gson gson = new Gson();

        // Reader r = new InputStreamReader(getJSONData("http://search.twitter.com/trends.json"));

        Reader r = new InputStreamReader(getJSONData("http://xxxx.com"));

        Log.i("MY INFO", r.toString());
        ResponseList objs = gson.fromJson(r, ResponseList.class);
        Log.i("MY INFO", ""+objs.getResponse().size());
        for(ResponseTag tr : objs.getResponse()){
            Log.i("Response", tr.getName() + " - " + tr.getUrl()+ "-"+ tr.getCustID());

        }

        }catch(Exception ex){
            ex.printStackTrace();
        }
    }


    public InputStream getJSONData(String url){
            DefaultHttpClient httpClient = new DefaultHttpClient();
            URI uri;
            InputStream data = null;
            try {
                uri = new URI(url);
                HttpGet method = new HttpGet(uri);
                HttpResponse response = httpClient.execute(method);
                data = response.getEntity().getContent();
            } catch (Exception e) {
                e.printStackTrace();
            }

    return data;
}
</code></pre>

<p>}</p>

<p>These three java claases are used in my project. It works perfectly and gives back a JSON response As:</p>

<p>{ "server_list" : [ { "CustID" : "23", "ServUser" : "Nathan", "ServPass" : "coffee00", "CustServersID" : "157", "ServURL" : "exp.lcgpence.com" }, ] } } </p>

<p>But when i try the same with different URL , it failed to worked.
After focusing on both JSON responses from two different URLs. I find one unique difference as:</p>

<p>{ "sessionId" : "000ASXeEL3381100000000LCG0", "responseCode" : 1, "data" : [ { "job_number" : "09-028", "contract_date" : {}, "project_title" : "Dayton School District Precon", "project_manager" : "Shaun Stuhldryer", "created_date" : "2009-06-11T13:22:08.000000580", "project_name" : "09028" }, { "job_number" : "09-053", "contract_date" : {}, "project_title" : "South Salem High School 2010 Renov.", "project_manager" : "Lee Zumwalt", "created_date" : "2009-11-30T14:38:43.000000573", "project_name" : "09053" }, { "job_number" : "09-011", "contract_date" : {}, "project_title" : "OFP New Concrete Floor - Bay 4", "project_manager" : "Jeff Perrin", "created_date" : "2009-01-19T11:12:56.000000113", "project_name" : "09011" }, { "job_number" : "08-020", "contract_date" : {}, "project_title" : "Clackamas Freezer Repair", "project_manager" : "Paul Schulz", "created_date" : "2008-04-02T11:43:40.000000050", "project_name" : "08020" }, { "job_number" : "07-018", "contract_date" : {}, "project_title" : "Shop Tenant Improvements LL Work", "project_manager" : "Jason Terry", "created_date" : "2007-02-22T17:33:07.000000920", "project_name" : "07018" }}]</p>

<p><strong>The Only diffrence is that in second Json response, i have to take "data" and parse inner values.</strong>
In, first one "server_list" which is the only tag.</p>

<p><strong>How to deserialise inner "data" tag ?</strong></p>
