diff --git a/hbase-client/pom.xml b/hbase-client/pom.xml
index 573b4b7485f4..d33db894f75b 100644
--- a/hbase-client/pom.xml
+++ b/hbase-client/pom.xml
@@ -252,6 +252,10 @@
junit
test
+
+ org.apache.hbase.thirdparty
+ hbase-shaded-gson
+
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/util/JsonMapper.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/util/JsonMapper.java
index 66b809b7c9b6..12a0a12a670b 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/util/JsonMapper.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/util/JsonMapper.java
@@ -18,12 +18,12 @@
*/
package org.apache.hadoop.hbase.util;
-import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.Map;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;
+import org.apache.hbase.thirdparty.com.google.gson.Gson;
/**
* Utility class for converting objects to JSON
@@ -34,12 +34,13 @@ public final class JsonMapper {
private JsonMapper() {
}
- private static final ObjectMapper MAPPER = new ObjectMapper();
+ private static final Gson GSON = GsonUtil.createGson().create();
- public static String writeMapAsString(Map map) throws IOException {
+ public static String writeMapAsString(Map map) throws IOException {
return writeObjectAsString(map);
}
- public static String writeObjectAsString(Object object) throws IOException {
- return MAPPER.writeValueAsString(object);
+
+ public static String writeObjectAsString(Object object) throws IOException {
+ return GSON.toJson(object);
}
}
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestOperation.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestOperation.java
index 0d82fac3c258..119d29a184d0 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestOperation.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestOperation.java
@@ -20,11 +20,10 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
+import java.lang.reflect.Type;
import java.nio.ByteBuffer;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -60,6 +59,9 @@
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.BuilderStyleTest;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.GsonUtil;
+import org.apache.hbase.thirdparty.com.google.gson.Gson;
+import org.apache.hbase.thirdparty.com.google.gson.reflect.TypeToken;
import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -75,7 +77,7 @@ public class TestOperation {
private static byte [] QUALIFIER = Bytes.toBytes("testQualifier");
private static byte [] VALUE = Bytes.toBytes("testValue");
- private static ObjectMapper mapper = new ObjectMapper();
+ private static Gson GSON = GsonUtil.createGson().create();
private static List TS_LIST = Arrays.asList(2L, 3L, 5L);
private static TimestampsFilter TS_FILTER = new TimestampsFilter(TS_LIST);
@@ -283,7 +285,9 @@ public void testOperationJSON() throws IOException {
scan.addColumn(FAMILY, QUALIFIER);
// get its JSON representation, and parse it
String json = scan.toJSON();
- Map parsedJSON = mapper.readValue(json, HashMap.class);
+ Type typeOfHashMap = new TypeToken