提供解析json的参考代码:
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-----------------
read1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View source) {
InputStream is = ReadJsonData.this.getResources()
.openRawResource(R.raw.test1);
String x;
try {
byte[] buffer = new byte[is.available()];
is.read(buffer);
String json = new String(buffer, "utf-8");
JSONObject act= new JSONObject(json);
x = act.getString("name");
Log.e("----name----", x);
x = act.getString("start");
Log.e("----age----", x);
} catch (Exception e) {
e.printStackTrace();
}
}
});