connectionUtils/src/main/java/com/ge/research/semtk/resultSet/Table.java
@SuppressWarnings({ "unchecked" })
	public JSONObject toJson(Boolean includeDataRows) throws Exception {

		JSONArray allRows = new JSONArray();
		int rowCount = 0;	
		
		// collect data rows in a JSONArray
		try {
			// we can do this faster. 
			int counter = 0;
			Integer[] columnNumbersInOrderIwanted = new Integer[this.columnNames.length];
			for (String colName : this.columnNames) {
				columnNumbersInOrderIwanted[counter] = getColumnIndex(colName);
				counter++;
			}
			if(includeDataRows){
				for (ArrayList<String> row : this.getRows()) {
					if(row != null){   // do not include null rows...
						JSONArray currRow = new JSONArray();
						for (Integer k : columnNumbersInOrderIwanted) {
							currRow.add(row.get(k));
						}
						allRows.add(currRow);
						rowCount += 1;
					}
				}
			}
			else{
				rowCount = this.getRows().size();
			}
		} catch(Exception e){
			throw new Exception("Unable to collect row data for JSON table result set: " + e.getMessage());
		}

		// get the columns into a JSON Array
		JSONArray colHeaders = new JSONArray();
		JSONArray colTypes = new JSONArray();
		try{
			for(int i = 0; i < this.columnNames.length; i++){
				colHeaders.add(columnNames[i]);
				colTypes.add(columnTypes[i]);  
			}
		}catch(Exception e){
			throw new Exception("Unable to collect column names/types for JSON table result set: " + e.getMessage());
		}

		// assemble the JSON object
		try{
			// create the table	
			JSONObject tbl = new JSONObject();
			if(includeDataRows){
				tbl.put(JSON_KEY_ROWS, allRows);			
			}
			tbl.put(JSON_TYPE, "TABLE");
			tbl.put(JSON_KEY_ROW_COUNT, rowCount);
			tbl.put(JSON_KEY_COL_NAMES, colHeaders);
			tbl.put(JSON_KEY_COL_TYPES, colTypes);
			tbl.put(JSON_KEY_COL_COUNT, this.columnNames.length);
			return tbl;

		} catch(Exception e){
			throw new Exception("Error assembling JSON table result set: " + e.getMessage());
		}
		
	}
/**
	 * Get table as json
	 * @param includeDataRows
	 * @return
	 * @throws Exception
	 */
Get table as json
@param includeDataRows
@return
@throws Exception
Get table as json @param includeDataRows @return @throws Exception
@SuppressWarnings({ "unchecked" })
	public JSONObject toJson(Boolean includeDataRows) throws Exception {
		JSONArray allRows = new JSONArray();
		int rowCount = 0;	
		try {
			int counter = 0;
			Integer[] columnNumbersInOrderIwanted = new Integer[this.columnNames.length];
			for (String colName : this.columnNames) {
				columnNumbersInOrderIwanted[counter] = getColumnIndex(colName);
				counter++;
			}
			if(includeDataRows){
				for (ArrayList<String> row : this.getRows()) {
					if(row != null){   
						JSONArray currRow = new JSONArray();
						for (Integer k : columnNumbersInOrderIwanted) {
							currRow.add(row.get(k));
						}
						allRows.add(currRow);
						rowCount += 1;
					}
				}
			}
			else{
				rowCount = this.getRows().size();
			}
		} catch(Exception e){
			throw new Exception("Unable to collect row data for JSON table result set: " + e.getMessage());
		}
		JSONArray colHeaders = new JSONArray();
		JSONArray colTypes = new JSONArray();
		try{
			for(int i = 0; i < this.columnNames.length; i++){
				colHeaders.add(columnNames[i]);
				colTypes.add(columnTypes[i]);  
			}
		}catch(Exception e){
			throw new Exception("Unable to collect column names/types for JSON table result set: " + e.getMessage());
		}
		try{
			JSONObject tbl = new JSONObject();
			if(includeDataRows){
				tbl.put(JSON_KEY_ROWS, allRows);			
			}
			tbl.put(JSON_TYPE, "TABLE");
			tbl.put(JSON_KEY_ROW_COUNT, rowCount);
			tbl.put(JSON_KEY_COL_NAMES, colHeaders);
			tbl.put(JSON_KEY_COL_TYPES, colTypes);
			tbl.put(JSON_KEY_COL_COUNT, this.columnNames.length);
			return tbl;
		} catch(Exception e){
			throw new Exception("Error assembling JSON table result set: " + e.getMessage());
		}
	}
@ SuppressWarnings ( { "unchecked" } ) public JSONObject toJson ( Boolean includeDataRows ) throws Exception { JSONArray allRows = new JSONArray ( ) ; int rowCount = 0 ; try { int counter = 0 ; Integer [ ] columnNumbersInOrderIwanted = new Integer [ this . columnNames . length ] ; for ( String colName : this . columnNames ) { columnNumbersInOrderIwanted [ counter ] = getColumnIndex ( colName ) ; counter ++ ; } if ( includeDataRows ) { for ( ArrayList < String > row : this . getRows ( ) ) { if ( row != null ) { JSONArray currRow = new JSONArray ( ) ; for ( Integer k : columnNumbersInOrderIwanted ) { currRow . add ( row . get ( k ) ) ; } allRows . add ( currRow ) ; rowCount += 1 ; } } } else { rowCount = this . getRows ( ) . size ( ) ; } } catch ( Exception e ) { throw new Exception ( "Unable to collect row data for JSON table result set: " + e . getMessage ( ) ) ; } JSONArray colHeaders = new JSONArray ( ) ; JSONArray colTypes = new JSONArray ( ) ; try { for ( int i = 0 ; i < this . columnNames . length ; i ++ ) { colHeaders . add ( columnNames [ i ] ) ; colTypes . add ( columnTypes [ i ] ) ; } } catch ( Exception e ) { throw new Exception ( "Unable to collect column names/types for JSON table result set: " + e . getMessage ( ) ) ; } try { JSONObject tbl = new JSONObject ( ) ; if ( includeDataRows ) { tbl . put ( JSON_KEY_ROWS , allRows ) ; } tbl . put ( JSON_TYPE , "TABLE" ) ; tbl . put ( JSON_KEY_ROW_COUNT , rowCount ) ; tbl . put ( JSON_KEY_COL_NAMES , colHeaders ) ; tbl . put ( JSON_KEY_COL_TYPES , colTypes ) ; tbl . put ( JSON_KEY_COL_COUNT , this . columnNames . length ) ; return tbl ; } catch ( Exception e ) { throw new Exception ( "Error assembling JSON table result set: " + e . getMessage ( ) ) ; } }
Get table as json
 @param includeDataRows
 @return
 @throws Exception
Get table as json @param includeDataRows @return @throws Exception
// collect data rows in a JSONArray // we can do this faster.  // do not include null rows... // get the columns into a JSON Array // assemble the JSON object // create the table	