일단 서버도받고 db에는 저장됩니다만 제가 json으로 파싱해서 보낸값을 다시 받아서 다른 액티비티에 뿌려줘야하는데 org.json.JSONObject cannot be converted to JSONArray와 같은에러가나며 키값을 출력하지못하고있습니다. 선생님들의 조언부탁드립니다.
protected void onPostExecute(String result) {
super.onPostExecute(result);
strJson = result;
writeAct.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(writeAct, "Received!", Toast.LENGTH_LONG).show();
try {
JSONArray json = new JSONArray(strJson);
JSONObject jona = json.optJSONObject(Integer.parseInt("strJson"));
JSONObject title = new JSONObject(jona.getString("postTitle"));
JSONObject name = new JSONObject(jona.getString("postName"));
JSONObject content = new JSONObject(jona.getString("postContent"));
// for (int i = 0; i < jona.length(); i++)
// {
// JSONObject jsonObject = jona.getJSONObject(String.valueOf(i));
// titleList.add(jsonObject.getString("postTitle"));
// nameList.add(jsonObject.getString("postName"));
// contentList.add(jsonObject.getString("postContent"));
// }
writeAct.postResult.setText(""+title+"\n"+""+name+"\n"+""+content);
// writeAct.postResult.setText(json.toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
}