コード例 #1
0
  private String[] parseJSONData(String result) {
    String zipCodeArray[] = null;
    try {
      JSONObject jsonObj = new JSONObject(result);
      JSONArray arrayList = (JSONArray) jsonObj.get("postalCodes");
      zipCodeArray = new String[arrayList.length()];
      String zipCode = null;
      int iActualCount = 0;
      for (int iIndexCount = 0; iIndexCount <= arrayList.length(); ++iIndexCount) {
        try {
          zipCode = (String) ((JSONObject) arrayList.get(iIndexCount)).get("postalCode");
          zipCodeArray[iActualCount] = zipCode;
          ++iActualCount;

        } catch (org.json.JSONException e) {
          e.printStackTrace();
        }
      }

    } catch (org.json.JSONException e) {
      e.printStackTrace();
    }

    return zipCodeArray;
  }
コード例 #2
0
  private String parseJSONDatatoGetState(String result) {
    String returnResult = null;
    try {
      JSONObject jsonObj = new JSONObject(result);
      JSONArray arrayList = (JSONArray) jsonObj.get("postalCodes");
      String zipCode = null;
      if (arrayList != null && arrayList.length() > 0) {
        returnResult = (String) ((JSONObject) arrayList.get(0)).get("adminCode1");
      }

    } catch (org.json.JSONException e) {
      e.printStackTrace();
    }

    return returnResult;
  }