After json conversion, wrapped list items can still need unwrapped. See
{@link ParquetGroupConverter#isWrappedListPrimitive(Object)} and
{@link ParquetGroupConverter#unwrapListPrimitive(Object)} for more details.

@param o

@return
342262
private Object finalizeConversion(Object o)
  {
    // conversion can leave 'wrapped' list primitives
    if (ParquetGroupConverter.isWrappedListPrimitive(o)) {
      return converter.unwrapListPrimitive(o);
    } else if (o instanceof List) {
      List<Object> asList = ((List<Object>) o).stream().filter(Objects::nonNull).collect(Collectors.toList());
      if (asList.stream().allMatch(ParquetGroupConverter::isWrappedListPrimitive)) {
        return asList.stream().map(Group.class::cast).map(converter::unwrapListPrimitive).collect(Collectors.toList());
      }
    }
    return o;
  }
769946
public static JsonValue serializeAsJson(Object o) throws IOException {
        try {
            return findFieldsToSerialize(o).mainObject;
        } catch (IllegalStateException ise) {
            // the reflective attempt to build the object failed.
            throw new IOException("Unable to build JSON for Object", ise);
        } catch (JsonException e) {
            throw new IOException("Unable to build JSON for Object", e);
        }
    }
1238667
@SuppressWarnings("unchecked")
    public static <K> List<K> list(Object o) {

        return (List<K>)o;
    }
521619
public static String serializeAsString(Object o) throws IOException {
        try {
            JsonStructure builtJsonObject = findFieldsToSerialize(o).mainObject;
            return builtJsonObject.toString();
        } catch (IllegalStateException ise) {
            // the reflective attempt to build the object failed.
            throw new IOException("Unable to build JSON for Object", ise);
        } catch (JsonException e) {
            throw new IOException("Unable to build JSON for Object", e);
        }
    }
1176877
public static boolean isBlankJson(final Object obj) {
        if (obj == null) {
            return true;
        }
        if(obj instanceof Collection) {
            return (((Collection) obj).size() == 0);
        }
        if(obj instanceof Map) {
            return (((Map) obj).size() == 0);
        }
        throw new UnsupportedOperationException("map or list is supported, got ${obj?obj.getClass():null}");
    }
232746
@SuppressWarnings("unchecked")
   public static <T> T unwrap(Object object)
   {
      T result = (T) object;

      if (object != null)
      {
         while (isForgeProxy(result))
         {
            try
            {
               Method method = result.getClass().getMethod("getDelegate");
               method.setAccessible(true);
               result = (T) method.invoke(result);
            }
            catch (Exception e)
            {
               break;
            }
         }

         if (result == null)
            result = (T) object;
      }
      return result;
   }
1323790
@SuppressWarnings("unchecked")
  private static List<String> toList(Object object) {
    List<String> list = new ArrayList<String>();

    if (object == null || object == JSONObject.NULL) {
      return null;
    }

    if (object instanceof List) {
      return ((List<String>) object);
    } else if (object instanceof JSONArray) {
      for (int i = 0; i < ((JSONArray) object).length(); i++) {
        try {
          list.add(String.valueOf((((JSONArray) object).get(i))));
        } catch (JSONException ex) {
          //issue converting the list. return null
          return null;
        }
      }
    } else {
      list.add(object.toString());
    }

    return list;
  }
735772
@Override
    protected byte[] serialize(Object o) {
        ClassLoaderRegisteringObjectInputStream.register(o.getClass());
        return super.serialize(o);
    }
571063
private <T> T convertObject(byte[] json, Class<T> claz) throws IOException {
        TypeReference<RestSuccessResult<Map<?, ?>>> typeReference = new TypeReference<RestSuccessResult<Map<?, ?>>>() {
        };
        RestSuccessResult<T> successResponse = MAPPER.readValue(json, typeReference);
        Map<?, ?> data = (Map<?, ?>) successResponse.getData();
        return MAPPER.convertValue(data, claz);
    }
128901
public static NodeList toNodeList(Object o, NodeList defaultValue) {
	// print.ln("nodeList:"+o);
	if (o instanceof NodeList) {
	    return (NodeList) o;
	}
	else if (o instanceof ObjectWrap) {
	    return toNodeList(((ObjectWrap) o).getEmbededObject(defaultValue), defaultValue);
	}
	return defaultValue;
    }
56706
@SuppressWarnings("unchecked")
	private Map<String, Object> o(Object obj) {
		return (Map<String, Object>) obj;
	}
1306560
private JSONObject jsonFromElement(final AtlasElement element) throws JSONException {
        final ObjectNode objectNode = this.objectNodeFromElement(element);

        try {
            return new JSONObject(new JSONTokener(MAPPER.writeValueAsString(objectNode)));
        } catch (IOException ioe) {
            // repackage this as a JSONException...seems sensible as the caller will only know about
            // the jettison object not being created
            throw new JSONException(ioe);
        }
    }
25159
public static Collection toCollection(Object o) throws PageException {
	if (o instanceof Collection) return (Collection) o;
	else if (o instanceof Node) return XMLCaster.toXMLStruct((Node) o, false);
	else if (o instanceof Map) {
	    return MapAsStruct.toStruct((Map) o, true);// StructImpl((Map)o);
	}
	else if (o instanceof ObjectWrap) {
	    return toCollection(((ObjectWrap) o).getEmbededObject());
	}
	else if (Decision.isArray(o)) {
	    return toArray(o);
	}
	throw new CasterException(o, "collection");
    }
57457
@SuppressWarnings("unchecked")
    public static <T extends Type> T unwrap(T type) {
        Type unwrapped = type;
        while (unwrapped instanceof SerializableTypeProxy) {
            unwrapped = ((SerializableTypeProxy) type).getTypeProvider().getType();
        }
        return (T) unwrapped;
    }
945485
public boolean add(Object o) {
		if (o instanceof ListItem) {
			ListItem item = (ListItem) o;
			Chunk chunk = new Chunk(preSymbol, symbol.getFont());
			chunk.append(String.valueOf((char)zn));
			chunk.append(postSymbol);
			item.setListSymbol(chunk);
			item.setIndentationLeft(symbolIndent, autoindent);
			item.setIndentationRight(0);
			list.add(item);
		} else if (o instanceof List) {
			List nested = (List) o;
			nested.setIndentationLeft(nested.getIndentationLeft() + symbolIndent);
			first--;
			return list.add(nested);
		} else if (o instanceof String) {
			return this.add(new ListItem((String) o));
		}
		return false;
	}
765232
public static @NonNull Throwable unwrap(final @NonNull Throwable throwable) {
    if(throwable instanceof InvocationTargetException) {
      final /* @Nullable */ Throwable cause = throwable.getCause();
      if(cause != null) {
        return cause;
      }
    }
    return throwable;
  }
44973
private String _serializeList(List list, Set<Object> done) throws ConverterException {
	StringBuilder sb = new StringBuilder(goIn() + "<array length=" + del + list.size() + del + ">");

	ListIterator it = list.listIterator();
	while (it.hasNext()) {
	    sb.append(_serialize(it.next(), done));
	}

	sb.append(goIn() + "</array>");
	return sb.toString();
    }