private static Object toJavaObject(JsonElement element) {
    if (element.isJsonNull()) {
      return null;
    } else if (element.isJsonPrimitive()) {
      JsonPrimitive primitive = element.getAsJsonPrimitive();
      if (primitive.isBoolean()) {
        return primitive.getAsBoolean();
      } else if (primitive.isNumber()) {
        return primitive.getAsNumber();
      } else if (primitive.isString()) {
        return primitive.getAsString();
      } else {
        return null;
      }
    } else if (element.isJsonArray()) {
      JsonArray array = element.getAsJsonArray();
      List<Object> list = new ArrayList<>();

      for (JsonElement arrayElement : array) {
        Object javaObject = toJavaObject(arrayElement);
        list.add(javaObject);
      }

      return list;
    } else if (element.isJsonObject()) {
      JsonObject object = element.getAsJsonObject();
      Map<String, Object> map = new LinkedHashMap<>();

      for (Entry<String, JsonElement> entry : object.entrySet()) {
        Object javaObject = toJavaObject(entry.getValue());
        map.put(entry.getKey(), javaObject);
      }

      return map;
    } else {
      return null;
    }
  }
This class converts PB Messages to various representations, like:
<ul>
<li>JSON string: {@link #toJsonElement(MessageOrBuilder)}</li>
<li>JSON object (gson): {@link #toJsonElement(MessageOrBuilder)}</li>
<li>Java objects (Boolean, Number, String, List, Map): {@link #toJavaObject(JsonElement)}</li>
</ul>
hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufMessageConverter.java