// Path: src/org/restsql/core/ResponseValue.java
// public class ResponseValue implements Comparable<ResponseValue> {
// 	private final String name;
// 	private final Object value;
// 	private final int columnNumber;
// 
// 	public ResponseValue(final String name, final Object value, final int columnNumber) {
// 		this.name = name;
// 		this.value = value;
// 		this.columnNumber = columnNumber;
// 	}
// 
// 	@Override
// 	public int compareTo(ResponseValue value) {
// 		if (columnNumber < value.getColumnNumber()) {
// 			return -1;
// 		} else if (columnNumber > value.getColumnNumber()) {
// 			return 1;
// 		} else {
// 			return 0;
// 		}
// 	}
// 
// 	/** Returns true if the names, values and column numbers are equal. */
// 	@Override
// 	public boolean equals(Object o) {
// 		return ((ResponseValue) o).getName().equals(name) && ((ResponseValue) o).getValue().equals(value)
// 				&& ((ResponseValue) o).getColumnNumber() == columnNumber;
// 	}
// 
// 	/** Returns column number in the select clause in the SQL Resource definition query. */
// 	public int getColumnNumber() {
// 		return columnNumber;
// 	}
// 
// 	/** Returns name. */
// 	public String getName() {
// 		return name;
// 	}
// 
// 	/** Returns value. */
// 	public Object getValue() {
// 		return value;
// 	}
// 	
// 	@Override
// 	public int hashCode() {
// 		return name.hashCode() + value.hashCode();
// 	}
// 
// 	/** Returns string representation in the form <code>name: value</code>. */
// 	@Override
// 	public String toString() {
// 		return name + ": " + value;
// 	}
// }
// 
// Path: src/org/restsql/core/SqlResource.java
// public interface SqlResource {
// 	/**
// 	 * Returns SQL resource information defined by the user, including query, validated attributes and trigger.
// 	 * 
// 	 * @return definition
// 	 */
// 	public SqlResourceDefinition getDefinition();
// 
// 	/**
// 	 * Returns SQL resource name.
// 	 * 
// 	 * @return SQL resource name
// 	 */
// 	public String getName();
// 
// 	/**
// 	 * Returns meta data for SQL resource.
// 	 * 
// 	 * @return SQL rsource meta data
// 	 */
// 	public SqlResourceMetaData getMetaData();
// 
// 	/**
// 	 * Returns triggers classes.
// 	 * 
// 	 * @return list of trigger classes
// 	 */
// 	public List<Trigger> getTriggers();
// 
// 	/**
// 	 * Executes query returning results as an object collection.
// 	 * 
// 	 * @param request Request object
// 	 * @throws SqlResourceException if a database access error occurs
// 	 * @return list of rows, where each row is a map of name-value pairs
// 	 */
// 	public List<Map<String, Object>> read(Request request) throws SqlResourceException;
// 
// 	/**
// 	 * Executes query returning results as a string.
// 	 * 
// 	 * @param request Request object
// 	 * @param mediaType response format, use internet media type e.g. application/xml
// 	 * @throws SqlResourceException if a database access error occurs
// 	 * @return list of rows, where each row is a map of name-value pairs
// 	 */
// 	public String read(final Request request, final String mediaType) throws SqlResourceException;
// 
// 	/**
// 	 * Executes database write (insert, update or delete).
// 	 * 
// 	 * @param request Request object
// 	 * @throws SqlResourceException if the request is invalid or a database access error or trigger exception occurs
// 	 * @return write response
// 	 */
// 	public WriteResponse write(final Request request) throws SqlResourceException;
// }


import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.restsql.core.ColumnMetaData;
import org.restsql.core.ResponseSerializer;
import org.restsql.core.ResponseValue;
import org.restsql.core.SqlResource;
import org.restsql.core.WriteResponse;
				} else {
					childRows = (List<Map<String, Object>>) value;
				}
			}

			// Do embedded child object columns
			if (level == 1 && childRows.size() > 0) {
				body.append(",\n\t\t\t\"");
				body.append(sqlResource.getMetaData().getChild().getRowSetAlias());
				body.append("\": [");
				serializeReadRowsHierarchical(sqlResource, childRows, body, 2);
				body.append("\n\t\t\t]");
			}

			// Add line ending
			if (level == 1 && childRows.size() > 0) {
				body.append("\n\t\t}");
			} else {
				body.append(" }");
			}

			if (!lastRow) {
				body.append(",");
			}
		}
	}

	/** One-level recursive method to serialize hierarchical results. */
	@SuppressWarnings("unchecked")
	private void serializeWriteRowsHierarchical(final SqlResource sqlResource,
// Path: src/org/restsql/core/ResponseValue.java
// public class ResponseValue implements Comparable<ResponseValue> {
// 	private final String name;
// 	private final Object value;
// 	private final int columnNumber;
// 
// 	public ResponseValue(final String name, final Object value, final int columnNumber) {
// 		this.name = name;
// 		this.value = value;
// 		this.columnNumber = columnNumber;
// 	}
// 
// 	@Override
// 	public int compareTo(ResponseValue value) {
// 		if (columnNumber < value.getColumnNumber()) {
// 			return -1;
// 		} else if (columnNumber > value.getColumnNumber()) {
// 			return 1;
// 		} else {
// 			return 0;
// 		}
// 	}
// 
// 	/** Returns true if the names, values and column numbers are equal. */
// 	@Override
// 	public boolean equals(Object o) {
// 		return ((ResponseValue) o).getName().equals(name) && ((ResponseValue) o).getValue().equals(value)
// 				&& ((ResponseValue) o).getColumnNumber() == columnNumber;
// 	}
// 
// 	/** Returns column number in the select clause in the SQL Resource definition query. */
// 	public int getColumnNumber() {
// 		return columnNumber;
// 	}
// 
// 	/** Returns name. */
// 	public String getName() {
// 		return name;
// 	}
// 
// 	/** Returns value. */
// 	public Object getValue() {
// 		return value;
// 	}
// 	
// 	@Override
// 	public int hashCode() {
// 		return name.hashCode() + value.hashCode();
// 	}
// 
// 	/** Returns string representation in the form <code>name: value</code>. */
// 	@Override
// 	public String toString() {
// 		return name + ": " + value;
// 	}
// }
// 
// Path: src/org/restsql/core/SqlResource.java
// public interface SqlResource {
// 	/**
// 	 * Returns SQL resource information defined by the user, including query, validated attributes and trigger.
// 	 * 
// 	 * @return definition
// 	 */
// 	public SqlResourceDefinition getDefinition();
// 
// 	/**
// 	 * Returns SQL resource name.
// 	 * 
// 	 * @return SQL resource name
// 	 */
// 	public String getName();
// 
// 	/**
// 	 * Returns meta data for SQL resource.
// 	 * 
// 	 * @return SQL rsource meta data
// 	 */
// 	public SqlResourceMetaData getMetaData();
// 
// 	/**
// 	 * Returns triggers classes.
// 	 * 
// 	 * @return list of trigger classes
// 	 */
// 	public List<Trigger> getTriggers();
// 
// 	/**
// 	 * Executes query returning results as an object collection.
// 	 * 
// 	 * @param request Request object
// 	 * @throws SqlResourceException if a database access error occurs
// 	 * @return list of rows, where each row is a map of name-value pairs
// 	 */
// 	public List<Map<String, Object>> read(Request request) throws SqlResourceException;
// 
// 	/**
// 	 * Executes query returning results as a string.
// 	 * 
// 	 * @param request Request object
// 	 * @param mediaType response format, use internet media type e.g. application/xml
// 	 * @throws SqlResourceException if a database access error occurs
// 	 * @return list of rows, where each row is a map of name-value pairs
// 	 */
// 	public String read(final Request request, final String mediaType) throws SqlResourceException;
// 
// 	/**
// 	 * Executes database write (insert, update or delete).
// 	 * 
// 	 * @param request Request object
// 	 * @throws SqlResourceException if the request is invalid or a database access error or trigger exception occurs
// 	 * @return write response
// 	 */
// 	public WriteResponse write(final Request request) throws SqlResourceException;
// }


// Path: src/org/restsql/core/impl/serial/JsonResponseSerializer.java
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.restsql.core.ColumnMetaData;
import org.restsql.core.ResponseSerializer;
import org.restsql.core.ResponseValue;
import org.restsql.core.SqlResource;
import org.restsql.core.WriteResponse;

				} else {
					childRows = (List<Map<String, Object>>) value;
				}
			}

			// Do embedded child object columns
			if (level == 1 && childRows.size() > 0) {
				body.append(",\n\t\t\t\"");
				body.append(sqlResource.getMetaData().getChild().getRowSetAlias());
				body.append("\": [");
				serializeReadRowsHierarchical(sqlResource, childRows, body, 2);
				body.append("\n\t\t\t]");
			}

			// Add line ending
			if (level == 1 && childRows.size() > 0) {
				body.append("\n\t\t}");
			} else {
				body.append(" }");
			}

			if (!lastRow) {
				body.append(",");
			}
		}
	}

	/** One-level recursive method to serialize hierarchical results. */
	@SuppressWarnings("unchecked")
	private void serializeWriteRowsHierarchical(final SqlResource sqlResource,
			final List<Set<ResponseValue>> rows, final StringBuilder body, final int level) {