Example usage for org.json JSONException printStackTrace

List of usage examples for org.json JSONException printStackTrace

Introduction

In this page you can find the example usage for org.json JSONException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:charitypledge.Pledge.java

public void JsonImport() {

    try {/*w w w.j  ava2 s .  c o  m*/
        InputStream foo = new FileInputStream(JSONFile);
        JSONTokener t = new JSONTokener(foo);
        JSONObject jsonObj = new JSONObject(t);
        foo.close();
        JSONArray jsonList = jsonObj.getJSONArray("contributors");
        for (int i = 0; i < jsonList.length(); i++) {
            // loop array
            JSONObject objects = jsonList.getJSONObject(i);
            String nameField = objects.getString("name");
            String typeField = objects.getString("charity");
            String contributionField = objects.getString("contribution");
            // Add row to jTable
            loadPledgeTable(nameField, typeField, contributionField);
        }
    } catch (FileNotFoundException e) {
        JSONWriter jsonWriter;
        try {
            jsonWriter = new JSONWriter(new FileWriter(JSONFile));
            jsonWriter.object();
            jsonWriter.key("contributors");
            jsonWriter.array();
            jsonWriter.endArray();
            jsonWriter.endObject();
            //jsonWriter.close();
            tableRefresh();
        } catch (IOException f) {
            f.printStackTrace();
        } catch (JSONException g) {
            g.printStackTrace();
        }
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:nl.hnogames.domoticzapi.Parsers.SwitchesParser.java

@Override
public void parseResult(String result) {
    try {// www. j  a  va  2 s. com
        JSONArray jsonArray = new JSONArray(result);
        ArrayList<SwitchInfo> mSwitches = new ArrayList<>();

        if (jsonArray.length() > 0) {
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject row = jsonArray.getJSONObject(i);
                mSwitches.add(new SwitchInfo(row));
            }
        }

        switchesReceiver.onReceiveSwitches(mSwitches);
    } catch (JSONException e) {
        Log.e(TAG, "ScenesParser JSON exception");
        e.printStackTrace();
        switchesReceiver.onError(e);
    }
}

From source file:koubachi.internal.json.JSONFactory.java

public ArrayList<Device> createDeviceList(String jsonData) {
    try {/* w w w  . ja va 2 s .  co m*/
        JSONArray jsonArray = new JSONArray(jsonData);
        return createDeviceList(jsonArray);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:koubachi.internal.json.JSONFactory.java

public Device createDevice(String jsonData) {
    try {/*from  w ww.  j a  v  a  2 s .c  o m*/
        JSONObject jsonObject = new JSONObject(jsonData);
        return createDevice(jsonObject);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:koubachi.internal.json.JSONFactory.java

private Device createDevice(JSONObject jsonObject) {
    try {//ww w  . j  a v a  2s .com
        Type collectionType = new TypeToken<Device>() {
        }.getType();
        return gson.fromJson(cleanDateFormat(jsonObject.getString("device")), collectionType);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:koubachi.internal.json.JSONFactory.java

public ArrayList<Plant> createPlantList(String jsonData) {
    try {/*w ww  .  j  av  a  2  s . com*/
        JSONArray jsonArray = new JSONArray(jsonData);
        return createPlantList(jsonArray);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return null;

}

From source file:koubachi.internal.json.JSONFactory.java

public Plant createPlant(String jsonData) {
    try {/*from   w ww  .  ja  v a2 s. c  om*/
        JSONObject jsonObject = new JSONObject(jsonData);
        return createPlant(jsonObject);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return null;

}

From source file:koubachi.internal.json.JSONFactory.java

private Plant createPlant(JSONObject jsonObject) {
    try {/*from  w ww .  jav a2s.c om*/
        Type collectionType = new TypeToken<Plant>() {
        }.getType();
        return gson.fromJson(cleanDateFormat(jsonObject.getString("plant")), collectionType);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:koubachi.internal.json.JSONFactory.java

public ArrayList<PlantCareAdvice> createPlantCareList(String jsonData) {
    try {//w  ww.j a va  2 s  .  c o m
        JSONArray jsonArray = new JSONArray(jsonData);
        return createPlantCareList(jsonArray);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:koubachi.internal.json.JSONFactory.java

public PlantCareAdvice createCareAdvice(String jsonData) {
    try {/*www. j a  v  a 2 s. c o m*/
        JSONObject jsonObject = new JSONObject(jsonData);
        return createCareAdvice(jsonObject);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return null;

}