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

请教关于2.0.2快照版本中JsonObject类继承LinkedHashMap去掉泛型<String, Object>用意 #120

Closed
T-Atlas opened this issue May 1, 2022 · 8 comments
Labels
question Further information is requested

Comments

@T-Atlas
Copy link

T-Atlas commented May 1, 2022

温少您好,我今日使用2.0.2快照版本发现JsonObject类继承LinkedHashMap去掉了泛型<String, Object>,因此我们原先代码中的jsonObj.entrySet()期望返回entry变成返回object,我不清楚这样更改后的用意,请指教

54b7580a7f0f9d6238be63f6eecfe4b
86e31421bd25b45c624c64db31dd7bc

private static String[] getCsvContents(JSONObject jsonObj, String[] csvHeaders, int i) {
        String[] csvContent = new String[csvHeaders.length];
        //TODO:BUG FIX HERE
        for (Map.Entry<String, Object> entry : jsonObj.entrySet()) {
            if (entry.getValue() instanceof String) {
                csvContent[i] = (String) entry.getValue();
            } else {
                //TODO:Check the update of fastjson2 2.0.2
                JSONObject innerJsonObj = jsonObj.getJSONObject(entry.getKey());
                Iterator<Map.Entry<String, Object>> iterator = innerJsonObj.entrySet().iterator();
                csvContent[i] = (String) iterator.next().getValue();
            }
            i++;
        }
        return csvContent;
    }
@T-Atlas
Copy link
Author

T-Atlas commented May 1, 2022

image

@wenshao
Copy link
Member

wenshao commented May 1, 2022

为了修复这个issue #110

@wenshao wenshao added the question Further information is requested label May 1, 2022
@T-Atlas
Copy link
Author

T-Atlas commented May 1, 2022

请问有没有迁移这段代码来适应新版本功能的建议写法呢/

@wenshao wenshao closed this as completed in b7a0583 May 1, 2022
@wenshao wenshao reopened this May 1, 2022
@wenshao
Copy link
Member

wenshao commented May 1, 2022

请更新快照再试试看

@T-Atlas
Copy link
Author

T-Atlas commented May 1, 2022

这个问题解决了,但是JSON.toJSONString中使用JSONWriter.Feature.WriteNonStringValueAsString属性对double和boolean不生效,只能吧int转换为String

@wenshao
Copy link
Member

wenshao commented May 1, 2022

你可以另外开一个issue并且能提供重现代码的例子么?

@T-Atlas
Copy link
Author

T-Atlas commented May 1, 2022

好的

@T-Atlas T-Atlas closed this as completed May 1, 2022
@MASON-PRINCE
Copy link

你可以另外开一个issue并且能提供重现代码的例子么?

issue125 已提供

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants