title: How can i get GSON to parse JSON String
body: <p>How can I get the <code>GSON</code> library to correctly convert the below <code>JSON</code> string to objects. I've tried for ages but it only seems to pick out the 2 "Word" objects and leave the member fields blank or null.</p>
  
  <p><strong>JSON:</strong></p>
  
  <pre><code>{
      "words": [
          {
              "Word": {
                  "id": "1",
                  "word": "submarine",
                  "word_syllables": "sub-mar-ine",
                  "picture": "none.jpg",
                  "soundfile": "",
                  "user_id": "1"
              }
          },
          {
              "Word": {
                  "id": "2",
                  "word": "computer",
                  "word_syllables": "com-pute-r",
                  "picture": "computer.jpg",
                  "soundfile": "",
                  "user_id": "0"
              }
          }
      ]
  }
  </code></pre>
  
  <p>I thought that the above could be created simply by having a class called "Words" which contains an arraylist/list of Word objects.</p>
  
  <p><strong>The Words class;</strong></p>
  
  <pre><code>package com.example.testgson.business;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import android.util.Log;
  
  public class Words {
      public List&lt;Word&gt; words=new ArrayList&lt;Word&gt;();
  
      public Words(){     
      }
  
      public int size(){
          return words.size();
      }
  
      public void addWord(Word w){
          this.words.add(w);
      }
  
  
      public List&lt;Word&gt; getWords() {
          return words;
          }
  
      public void setWords(List&lt;Word&gt; words) {
          this.words = words;
      }
  
  
      public void printAll(){         
          for(int i=0; i&lt;words.size();i++){
              Word w=(Word) words.get(i);
              if(w!=null){
                  Log.d("word",w.getWord());
              }
          }       
      }
  
  
      public List &lt;Word&gt; getWordList(){
          return this.words;
      }   
  }
  </code></pre>
  
  <p><strong>The Word Class;</strong></p>
  
  <pre><code>public class Word {
  
      int id;
      String word;
      String word_syllables;
      String picture;
      String soundfile;
      int user_id;
  
      public Word(){
  
      }
  
      public Word(int id, String word, String word_syllables, String picture,
              String soundfile, int user_id) {
          super();
          this.id = id;
          this.word = word;
          this.word_syllables = word_syllables;
          this.picture = picture;
          this.soundfile = soundfile;
          this.user_id = user_id;
      }
  
  
  
  
  
      @Override
      public String toString() {
          return "Word [id=" + id + ", word=" + word + ", word_syllables="
                  + word_syllables + ", picture=" + picture + ", soundfile="
                  + soundfile + ", user_id=" + user_id + "]";
      }
  
      public int getId() {
          return id;
      }
      public void setId(int id) {
          this.id = id;
      }
      public String getWord() {
          return this.word;
      }
      public void setWord(String word) {
          this.word = word;
      }
      public String getWord_syllables() {
          return word_syllables;
      }
      public void setWord_syllables(String word_syllables) {
          this.word_syllables = word_syllables;
      }
      public String getPicture() {
          return picture;
      }
      public void setPicture(String picture) {
          this.picture = picture;
      }
      public String getSoundfile() {
          return soundfile;
      }
      public void setSoundfile(String soundfile) {
          this.soundfile = soundfile;
      }
      public int getUser_id() {
          return user_id;
      }
      public void setUser_id(int user_id) {
          this.user_id = user_id;
      }    
  }
  </code></pre>
  
  <p><strong>GSON convert code;</strong></p>
  
  <pre><code>Gson gson = new Gson();         
  Words obj = gson.fromJson(sjson, Words.class);  
  </code></pre>