@Override
    public void writeTo(
            Object obj,
            Class<?> type,
            Type genericType,
            Annotation[] annotations,
            MediaType mediaType,
            MultivaluedMap<String, Object> httpHeaders,
            OutputStream entityStream
    ) throws IOException, WebApplicationException {
        FastJsonConfig fastJsonConfig = locateConfigProvider(type, mediaType);
        SerializerFeature[] serializerFeatures = fastJsonConfig.getSerializerFeatures();

        if (pretty) {
            if (serializerFeatures == null) {
                serializerFeatures = new SerializerFeature[]{SerializerFeature.PrettyFormat};
            } else {
                List<SerializerFeature> featureList = new ArrayList<>(Arrays.asList(serializerFeatures));
                featureList.add(SerializerFeature.PrettyFormat);
                serializerFeatures = featureList.toArray(serializerFeatures);
            }
            fastJsonConfig.setSerializerFeatures(serializerFeatures);
        }

        try {
            writeJSONStringWithFastJsonConfig(
                    entityStream,
                    fastJsonConfig.getCharset(),
                    obj,
                    fastJsonConfig.getSerializeConfig(),
                    fastJsonConfig.getSerializeFilters(),
                    fastJsonConfig.getDateFormat(),
                    JSON.DEFAULT_GENERATE_FEATURE,
                    fastJsonConfig.getSerializerFeatures()
            );

            entityStream.flush();
        } catch (JSONException ex) {
            throw new WebApplicationException(ex);
        }
    }
Method that JAX-RS container calls to serialize given value.
fastjson1-compatible/src/main/java/com/alibaba/fastjson/support/jaxrs/FastJsonProvider.java