if (serializeRows) {
logger.debug("Serializing rows into JSON result structure...");
RowIterator rows = result.getRows();
int resultCount = 0;
while (rows.hasNext()) {
Row row = rows.nextRow();
JSONObject serializedRow = serializeRow(row, columns, depth, escape, alreadyIncludedIdentifiers, propertyMatchRegexp, alreadyIncludedPropertyValues);
if (serializedRow != null) {
results.put(serializedRow);
resultCount++;
}