Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于JSONObject对象toString的方法是不是可以加个支持SerializerFeature重载呢? #2074

Closed
syphgxrsn opened this issue Sep 20, 2018 · 2 comments
Assignees
Milestone

Comments

@syphgxrsn
Copy link

syphgxrsn commented Sep 20, 2018

关于JSONObject对象toString的方法是不是可以加个支持SerializerFeature重载呢?
目前 JSONObject对象toString或toJSONString都不支持设置SerializerFeature,每次toString的时候必须都折中使用

    JSON.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue);

这样的方式看起来一点儿也不优雅。建议在com.alibaba.fastjson.JSON中添加 toString(SerializerFeature... features)方法。

    public static String toJSONString(SerializerFeature... features) {
        SerializeWriter out = new SerializeWriter(features);

        try {
            new JSONSerializer(out).write(this);
            return out.toString();
        } finally {
            out.close();
        }
    }

    public static String toString(SerializerFeature... features) {
        return toJSONString(features);
    }

@wenshao wenshao added this to the 1.2.52 milestone Sep 21, 2018
@wenshao
Copy link
Member

wenshao commented Sep 21, 2018

你来提交个patch?

@wenshao
Copy link
Member

wenshao commented Apr 11, 2019

https://github.com/alibaba/fastjson/releases/tag/1.2.57
问题已修复,请用新版本

@wenshao wenshao closed this as completed Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants