### Question:
RowUtil { public static String rowToJson(Row row, String[] colName) { Preconditions.checkNotNull(colName); Map<String,Object> map = new LinkedHashMap<>(colName.length); for(int i = 0; i < colName.length; ++i) { String key = colName[i]; Object value = row.getField(i); map.put(key, value); } return gson.toJson(map); }  static String rowToJson(Row row, String[] colName);  }### Answer:
@Test public void testRowToJson() { Row row = new Row(2); row.setField(0, 1); row.setField(1, "val"); String result = RowUtil.rowToJson(row, new String[]{"col1", "col2"}); Assert.assertEquals(result, "{\"col1\":1,\"col2\":\"val\"}"); }