@Test
  public void testOperationJSON() throws IOException {
    // produce a Scan Operation
    Scan scan = new Scan().withStartRow(ROW);
    scan.addColumn(FAMILY, QUALIFIER);
    // get its JSON representation, and parse it
    String json = scan.toJSON();
    Type typeOfHashMap = new TypeToken<Map<String, Object>>() {
    }.getType();
    Map<String, Object> parsedJSON = GSON.fromJson(json, typeOfHashMap);
    // check for the row
    assertEquals("startRow incorrect in Scan.toJSON()", Bytes.toStringBinary(ROW),
      parsedJSON.get("startRow"));
    // check for the family and the qualifier.
    List familyInfo = (List) ((Map) parsedJSON.get("families")).get(Bytes.toStringBinary(FAMILY));
    assertNotNull("Family absent in Scan.toJSON()", familyInfo);
    assertEquals("Qualifier absent in Scan.toJSON()", 1, familyInfo.size());
    assertEquals("Qualifier incorrect in Scan.toJSON()", Bytes.toStringBinary(QUALIFIER),
      familyInfo.get(0));

    // produce a Get Operation
    Get get = new Get(ROW);
    get.addColumn(FAMILY, QUALIFIER);
    // get its JSON representation, and parse it
    json = get.toJSON();
    parsedJSON = GSON.fromJson(json, typeOfHashMap);
    // check for the row
    assertEquals("row incorrect in Get.toJSON()", Bytes.toStringBinary(ROW), parsedJSON.get("row"));
    // check for the family and the qualifier.
    familyInfo = (List) ((Map) parsedJSON.get("families")).get(Bytes.toStringBinary(FAMILY));
    assertNotNull("Family absent in Get.toJSON()", familyInfo);
    assertEquals("Qualifier absent in Get.toJSON()", 1, familyInfo.size());
    assertEquals("Qualifier incorrect in Get.toJSON()", Bytes.toStringBinary(QUALIFIER),
      familyInfo.get(0));

    // produce a Put operation
    Put put = new Put(ROW);
    put.addColumn(FAMILY, QUALIFIER, VALUE);
    // get its JSON representation, and parse it
    json = put.toJSON();
    parsedJSON = GSON.fromJson(json, typeOfHashMap);
    // check for the row
    assertEquals("row absent in Put.toJSON()", Bytes.toStringBinary(ROW), parsedJSON.get("row"));
    // check for the family and the qualifier.
    familyInfo = (List) ((Map) parsedJSON.get("families")).get(Bytes.toStringBinary(FAMILY));
    assertNotNull("Family absent in Put.toJSON()", familyInfo);
    assertEquals("KeyValue absent in Put.toJSON()", 1, familyInfo.size());
    Map kvMap = (Map) familyInfo.get(0);
    assertEquals("Qualifier incorrect in Put.toJSON()", Bytes.toStringBinary(QUALIFIER),
      kvMap.get("qualifier"));
    assertEquals("Value length incorrect in Put.toJSON()", VALUE.length,
      ((Number) kvMap.get("vlen")).intValue());

    // produce a Delete operation
    Delete delete = new Delete(ROW);
    delete.addColumn(FAMILY, QUALIFIER);
    // get its JSON representation, and parse it
    json = delete.toJSON();
    parsedJSON = GSON.fromJson(json, typeOfHashMap);
    // check for the row
    assertEquals("row absent in Delete.toJSON()", Bytes.toStringBinary(ROW), parsedJSON.get("row"));
    // check for the family and the qualifier.
    familyInfo = (List) ((Map) parsedJSON.get("families")).get(Bytes.toStringBinary(FAMILY));
    assertNotNull("Family absent in Delete.toJSON()", familyInfo);
    assertEquals("KeyValue absent in Delete.toJSON()", 1, familyInfo.size());
    kvMap = (Map) familyInfo.get(0);
    assertEquals("Qualifier incorrect in Delete.toJSON()", Bytes.toStringBinary(QUALIFIER),
      kvMap.get("qualifier"));
  }
Test the client Operations' JSON encoding to ensure that produced JSON is parseable and that
the details are present and not corrupted.
@throws IOException if the JSON conversion fails
hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestOperation.java