static String toJSONString(Object object) {
        final ObjectWriterProvider provider = defaultObjectWriterProvider;
        final JSONWriter.Context context = new JSONWriter.Context(provider);
        try (JSONWriter writer = JSONWriter.of(context)) {
            if (object == null) {
                writer.writeNull();
            } else {
                writer.rootObject = object;
                writer.path = JSONWriter.Path.ROOT;

                Class<?> valueClass = object.getClass();
                if (valueClass == JSONObject.class && context.features == 0) {
                    writer.write((JSONObject) object);
                } else {
                    ObjectWriter<?> objectWriter = provider.getObjectWriter(
                            valueClass,
                            valueClass,
                            (defaultWriterFeatures & JSONWriter.Feature.FieldBased.mask) != 0
                    );
                    objectWriter.write(writer, object, null, null, 0);
                }
            }
            return writer.toString();
        } catch (NullPointerException | NumberFormatException e) {
            throw new JSONException("JSON#toJSONString cannot serialize '" + object + "'", e);
        }
    }
Serializes the specified object to the json string

@param object the specified object will be serialized
@return {@link String} that is not null
@throws JSONException If a serialization error occurs
core/src/main/java/com/alibaba/fastjson2/JSON.java