private Map<Object, Object> visitMapNode(final JsonNode rootNode,
      final ObjectInspector oi) throws SerDeException {
    Preconditions.checkArgument(JsonNodeType.OBJECT == rootNode.getNodeType());

    final Map<Object, Object> ret = new LinkedHashMap<>();

    final ObjectInspector mapKeyInspector =
        ((MapObjectInspector) oi).getMapKeyObjectInspector();

    final ObjectInspector mapValueInspector =
        ((MapObjectInspector) oi).getMapValueObjectInspector();

    if (!(mapKeyInspector instanceof PrimitiveObjectInspector)) {
      throw new SerDeException("Map key must be a primitive type");
    }

    final Iterator<Entry<String, JsonNode>> it = rootNode.fields();
    while (it.hasNext()) {
      final Entry<String, JsonNode> field = it.next();
      final Object key =
          visitNode(new TextNode(field.getKey()), mapKeyInspector);
      final Object val = visitNode(field.getValue(), mapValueInspector);
      ret.put(key, val);
    }

    return ret;
  }
Visit a node if it is expected to be a Map (a.k.a. JSON Object)

@param rootNode The node pointing at the JSON object
@param oi The ObjectInspector to parse the Map (must be a
         MapObjectInspector)
@return A Java Map containing the contents of the JSON map
@throws SerDeException The SerDe is not configured correctly
serde/src/java/org/apache/hadoop/hive/serde2/json/HiveJsonReader.java