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

[BUG] 当重复key的数量大于2时,DuplicateKeyValueAsArray这个feature失效 #1100

Closed
yzezzm opened this issue Feb 8, 2023 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@yzezzm
Copy link

yzezzm commented Feb 8, 2023

问题描述

当json object中同名的key有三个时,使用DuplicateKeyValueAsArray后,实际得到的value只有一个,而不是一个数组

环境信息

  • OS信息: [macos 13.1 16 GB]
  • JDK信息: [Openjdk 18.0.2]
  • 版本信息:[Fastjson2 2.0.21]

重现步骤

String str = "{"a":2,"b":1,"b":2,"b":3}";
JSONObject jsonObject = JSON.parseObject(str, JSONReader.Feature.DuplicateKeyValueAsArray);
String b = jsonObject.get("b").toString();


输出结果为: 3

期待的正确结果

[1,2,3]

附加信息

com.alibaba.fastjson2.JSONReader#readObject(java.lang.Object, long)

2.0.21 版本 com.alibaba.fastjson2.JSONReader这个类的1556行,value应替换为origin

image

@yzezzm yzezzm added the bug Something isn't working label Feb 8, 2023
@wenshao
Copy link
Member

wenshao commented Feb 9, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.24-SNAPSHOT/
问题已修复,请用2.0.24-SNAPSHOT版本帮忙验证,2.0.24-SNAPSHOT预计在2月中旬发布。

@wenshao wenshao added the fixed label Feb 9, 2023
@wenshao wenshao added this to the 2.0.24 milestone Feb 9, 2023
@yzezzm
Copy link
Author

yzezzm commented Feb 9, 2023

验证ok

@yzezzm yzezzm closed this as completed Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants