How to get a specific value from a multi-layer array in Java
<p>I'm learnign to use Java to parse JSON feeds returned from PHP scripts.</p>

<p>Example feed:</p>

<pre><code>{"specification":{"result":{"feature":[{"name":"attribute A","value":"50"}]}}}
</code></pre>

<p>I use <code>gson</code> for the task but I am struggling to access a specific value from the array of objects. For example, I want to get the value of "name" <code>attribute A</code> in the first object of the array "feature". However I'm receiving a "name cannot be resolved or not a field" error.</p>

<pre><code>    public static String show() throws Exception {

        String json = Json.fetch("http://somthing.json");

        Gson gson = new Gson(); 

        Model result = gson.fromJson(json, Model.class);

        return result.specification.get("result").feature[0].name; //Error : name cannot be resolved or not a field
    }
</code></pre>

<p>Here is the entire class I came up:</p>

<pre><code> public class Item {

    static class Model{
        HashMap &lt;String,Item.Data&gt; specification;
    }

    static class Data{
        ArrayList &lt;Item.Attribute&gt; feature[];
    }

    static class Attribute{
        String value;
        String name;
    }

    public static String show() throws Exception {

        String json = Json.fetch("http://somthing.json");

        Gson gson = new Gson(); 

        Model result = gson.fromJson(json, Model.class);

        return result.specification.get("result").feature[0].name;

    }

}
</code></pre>

<p>Can anyone show me how to get the name <code>attribute A</code>? Thank you.</p>