아래와 같은 경우
String Json = {"id" : "home01", "title" : "테스트버튼"};
구문의 : 부분에서 syntax error 가 발생합니다.
문법은 맞는것 같은데 왜 그럴까요?
String Json = {"id" : "home01", "title" : "테스트버튼"};
try {
String Result = "테스트\n";
JSONArray ja = new JSONArray(Json);
for (int i = 0; i < ja.length(); i++) {
JSONObject order = ja.getJSONObject(i);
Result += order.getString("id")+" "+order.getString("title")+ "\n";
}
Toast.makeText(JsonTest.this, Result, 1).show();
} catch (JSONException e) {
Toast.makeText(v.getContext(), e.getMessage(), 0).show();
따옴표로 묶는다는것이 String Json = {"id" : "home01", "title" : "테스트버튼"};
를 String Json = "{"id" : "home01", "title" : "테스트버튼"}"; 나 String Json = '{"id" : "home01", "title" : "테스트버튼"}';
로 한다는 말씀이시죠? 역시 구문에러가 발생합니다. --;;
{} 로 되었으니 처음 getJSONArray 가 아닌 JSONObject로 받아와야 할 듯 싶네요
아니면 [{}] 로 묶어서 JSONArray 로 받으시던가요



