JSON (JavaScript Object Notation)
- 가벼운 데이터 변환 포멧

Sample data
{"result":"success", "value":"0", "list":[...]}


Simple Code
import org.codehaus.jettison.json.JSONObject;
import org.apache.cxf.helpers.IOUtils;

JSONObject json = new JSONObject(IOUtils.toString(in));
System.out.println(json.getString("result"));
System.out.println(json.getString("value"));

List Code
JSONObject jsonObject = new JSONObject(IOUtils.toString(in));
JSONArray jsonArray = jsonObject .getJSONArray("list");

for(int i = 0 ; i < jsonArray .length() ; i++){
    JSONObject listJson= jsonArray .getJSONObject(i);
    System.out.println(listJson.getString("result"));
    System.out.println(listJson.getString("value"));
}



Posted by 짱가쟁이