public void parseJSON(JSONObject sourceObj) { JSONString type = (JSONString) sourceObj.get("type"); JSONString componentID = (JSONString) sourceObj.get("componentID"); JSONString componentDescription = (JSONString) sourceObj.get("componentDescription"); JSONString fileName = (JSONString) sourceObj.get("fileName"); JSONString loadFunction = (JSONString) sourceObj.get("loadFunction"); JSONNumber xcoor = (JSONNumber) sourceObj.get("xcoor"); JSONNumber ycoor = (JSONNumber) sourceObj.get("ycoor"); setComponentID(componentID.stringValue()); setComponentDescription(componentDescription.stringValue()); setFileName(fileName.stringValue()); setLeft(xcoor.doubleValue()); setTop(ycoor.doubleValue()); JSONArray ports = (JSONArray) sourceObj.get("ports"); for (int i = 0; i < ports.size(); i++) { JSONObject portobj = (JSONObject) ports.get(i); JSONString porttype = (JSONString) portobj.get("porttype"); // JSONString dataSet = (JSONString) portobj.get("dataSet"); JSONArray dataDefinition = (JSONArray) portobj.get("dataSet"); for (int j = 0; j < dataDefinition.size(); j++) { JSONObject entry = (JSONObject) dataDefinition.get(j); JSONNumber order = (JSONNumber) entry.get("order"); JSONString fieldName = (JSONString) entry.get("fieldName"); JSONString fieldType = (JSONString) entry.get("fieldType"); getPort(porttype.stringValue()) .getDataSet() .add( new DataDefinitionEntry( Integer.parseInt(order.toString()), fieldName.stringValue(), fieldType.stringValue())); } } }