title: Cannot find local variable "bv" Trying to turn my json file into objects
body: <p>I am new to Android Java. I have an error of "cannot find the local variable vs".  Did I do something wrong?  I cannot make my json file into objects...Please help.  Thanks.</p>
  
  <pre><code>The following is my json file.
  
      "bv": [
          {
              "topic": "topic1",
              "vs": [
                      {
                              "idnum": "1",
                              "vn": "vn1",
                              "v": "v1 sentence"
  
                       },
  
                       {
                              "idnum": "2",
                              "vn": "vn2",
                              "v": "v2 sentence"
  
                       }
  
                         ]
           },
           {
              "topic": "topic2",
             "vs": [
                         {
                               "idnum": "3",
                                "vn": "vn3",
                                "v": "v3 sentence"
  
                         },
  
                         {
                                "idnum": "4",
                                "vn": "vn4",
                                "v": "v4 sentence",
  
  
                         }
  
                        ]
  
          }
  
  ]
  }
  </code></pre>
  
  <p>And the class as follow:</p>
  
  <pre><code>    public class BV {
  
      String topic;
      ArrayList &lt;VS&gt; vs;
  
      public String gettopic() {
          return topic;
      }
      public void settopic(String topic) {
          this.topic = topic;
      }
  
  
  }
  
      public class VS {
  
  
          private String idnum;
          private String vn;
          private String v;
  
  
  
          public void setidnum(String idnum) {
              this.idnum = idnum;
          }
  
          public String getidnum() {
              return idnum;
          }
  
          public String getVn() {
  
              return vn;
          }
  
          public void setVn(String vn) {
  
              this.vn = vn;
          }
  
          public String getV() {
              return v;
          }
          public void setV(String v) {
              this.v = v;
          }
  
  
  }
  </code></pre>
  
  <p>And the following is my main class. </p>
  
  <pre><code> public class MainActivity extends AppCompatActivity {
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          String jsonFile = loadJSONFromAsset();
  
          try {
              ObjectMapper mapper = new ObjectMapper();
              BV bv = mapper.readValue(jsonFile, BV.class);
  
              System.out.println("BV.topic = " + bv.topic);
  
          }catch (IOException e) {
              e.printStackTrace();
          }
  
  
  
      }
  
      public String loadJSONFromAsset() {
  
          String json = null;
          try {
  
              InputStream is = getAssets().open("data.json");
  
              int size = is.available();
  
              byte[] buffer = new byte[size];
  
              is.read(buffer);
  
              is.close();
  
              json = new String(buffer, "UTF-8");
  
  
          } catch (IOException ex) {
              ex.printStackTrace();
              return null;
          }
          return json;
  
      }
  
  
  
  }
  </code></pre>