public static void serializeObject(String fieldName, Object obj, JsonGenerator jsonGenerator) throws TikaSerializationException {


        try {
            Constructor constructor = obj
                    .getClass()
                    .getConstructor();
        } catch (NoSuchMethodException e) {
            throw new IllegalArgumentException("class (" + obj.getClass() + ") doesn't have a no-arg constructor. Respectfully not serializing.");
        }
        try {
            if (fieldName != null) {
                jsonGenerator.writeFieldName(fieldName);
            }
            jsonGenerator.writeStartObject();
            jsonGenerator.writeStringField(INSTANTIATED_CLASS_KEY, obj
                    .getClass()
                    .getName());
            Map<String, Method> matches = getGetters(obj
                    .getClass()
                    .getMethods());
            //iterate through the getters
            for (Map.Entry<String, Method> e : matches.entrySet()) {
                try {
                    Object methodVal = e
                            .getValue()
                            .invoke(obj);
                    serialize(e.getKey(), methodVal, jsonGenerator);
                } catch (IllegalAccessException | InvocationTargetException ex) {
                    throw new TikaSerializationException("couldn't write paramName=" + e.getKey(), ex);
                }
            }

            jsonGenerator.writeEndObject();
        } catch (IOException e) {
            throw new TikaSerializationException("couldn't serialize", e);
        }
    }
@param fieldName     can be null -- used only for logging and debugging
@param obj
@param jsonGenerator
@throws TikaSerializationException
tika-serialization/src/main/java/org/apache/tika/serialization/TikaJsonSerializer.java