private ObjectNode visitUnion(final ObjectInspector oi, final Object o)
      throws SerDeException {
    final UnionObjectInspector unionInspector = (UnionObjectInspector) oi;

    final ObjectNode unionNode = this.nodeFactory.objectNode();

    final byte tag = unionInspector.getTag(o);
    final String tagText = Byte.toString(tag);
    final JsonNode valueNode =
        walkObjectGraph(unionInspector.getObjectInspectors().get(tag),
            unionInspector.getField(o), Collections.emptyList());

    unionNode.set(tagText, valueNode);

    return unionNode;
  }
Visit a vertex in the graph that is a union data type.

@param oi The union's ObjectInspector
@param o The Union object
@return A JsonNode representation of the union
@throws SerDeException The union cannot be parsed
serde/src/java/org/apache/hadoop/hive/serde2/json/HiveJsonWriter.java