java - open the object in JSON package -


i ran problem can not have way solve. hope understand me better. code guidefragment.java

package ru.yktdevelopers.childrensofasia;   import android.os.bundle; import android.support.annotation.nullable; import android.support.v4.app.fragment; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.listview;  import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject;  import java.util.arraylist;  import ru.yktdevelopers.childrensofasia.download_data.download_complete;  public class guidefragment extends fragment implements download_complete {      public listview list;     public arraylist<countries> countries = new arraylist<countries>();     public listadapter adapter;      @nullable     @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {         view v = inflater.inflate(r.layout.guide_fragment, null);          list = (listview) v.findviewbyid(r.id.list_guide);         adapter = new listadapter(this);         list.setadapter(adapter);          download_data download_data = new download_data((download_complete) this);         download_data.download_data_from_link("http://9142218380.myjino.ru/testfile.json");          return v;     }      public void get_data(string data)     {         try {             jsonarray data_array=new jsonarray(data);              (int = 0 ; < data_array.length() ; i++)             {                 jsonobject obj=new jsonobject(data_array.get(i).tostring());                  countries add=new countries();                 add.name = obj.getstring("country");                 add.code = obj.getstring("code");                  countries.add(add);              }              adapter.notifydatasetchanged();          } catch (jsonexception e) {             e.printstacktrace();         }     }      public class countries {         string name;         string code;     } } 

the problem is: how make able open object name "test".

json file located http://9142218380.myjino.ru/testfile.json

replace functions first line after try

jsonarray data_array=new jsonarray(new jsonobject(data).getjsonarray("test")); 

and pass whole data server string


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -