* JSON DATA

1
2
3
4
5
6
7
8
9
10
11
{  // json object node
    "response":{ // json object response
        "header":{ // json object header
            "resultCode":"00",
            "resultMsg":"NORMAL SERVICE."},
        "body":{ // json object body
            "items":{ // json object body
                "item":[ // json array item
                    { //json object node
                        "arrprevstationcnt":9,
                        "arrtime":720,
cs

 

* Parsing source

1
2
3
4
5
6
7
8
  JSONObject mmJsonObject = new JSONObject("JSON DATA").getJSONObject("items");
    JSONArray mmJsonArray = mmJsonObject.getJSONArray("item");
 
        for (int i = 0; i < mmJsonArray.length(); i++) {
            HashMap<StringString> mmBusHash = new HashMap<>();
            JSONObject obj = mmJsonArray.getJSONObject (i);
            mmBusHash.put ( Key.BUS_STOP , obj.getString ( "nodenm" ));
            mmBusHash.put ( Key.BUS_NUM , obj.getString ( "arrtime" ));
cs

 

 

참고 : https://stackoverflow.com/questions/20653106/json-type-mismatch-or-org-json-jsonecxeption

+ Recent posts