public Response addPcParts2(String incomingData) throws Exception {
String returnString = null;
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
Schema308tube dao = new Schema308tube();
try {
/*
* We can create a new instance and it will accept a JSON string
* By doing this, we can now access the data.
*/
JSONObject partsData = new JSONObject(incomingData);
System.out.println( "jsonData: " + partsData.toString() );
/*
* In order to access the data, you will need to use one of the method in JSONArray
* or JSONObject. I recommend using the optXXXX methods instead of the get method.
*
* Example:
* partsData.get("PC_PARTS_TITLE");
* The example above will get you the data, the problem is, if PC_PARTS_TITLE does
* not exist, it will generate a java error. If you are using get, you need to use
* the has method first partsData.has("PC_PARTS_TITLE");.
*
* Example:
* partsData.optString("PC_PARTS_TITLE");
* The optString example above will also return data but if PC_PARTS_TITLE does not
* exist, it will return a BLANK string.
*
* partsData.optString("PC_PARTS_TITLE", "NULL");
* You can add a second parameter, it will return NULL if PC_PARTS_TITLE does not
* exist.
*/
int http_code = dao.insertIntoPC_PARTS(partsData.optString("PC_PARTS_TITLE"),
partsData.optString("PC_PARTS_CODE"),
partsData.optString("PC_PARTS_MAKER"),
partsData.optString("PC_PARTS_AVAIL"),
partsData.optString("PC_PARTS_DESC") );