We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
class JavaObj { HashMap<Integer, Integer> map = new HashMap<>(); public JavaObj() { } public JavaObj(HashMap<Integer, Integer> map) { super(); this.map = map; } public HashMap<Integer, Integer> getMap() { return map; } public void setMap(HashMap<Integer, Integer> map) { this.map = map; } public static void main(String[] args) { HashMap<Integer, Integer> map = new HashMap<>(); map.put(1, 1); map.put(2, 2); JavaObj o = new JavaObj(map); byte[] bt = JSON.toJSONBytes(o, JSONWriter.Feature.WriteNonStringKeyAsString); // 兼容其他语言 JSONObject jsonObj = JSON.parseObject(bt); System.out.println(jsonObj.toString()); o = jsonObj.to(JavaObj.class, JSONReader.Feature.FieldBased); System.out.println(o.getMap().get(1)); // 这里泛型不匹配, String的key没有自动转为int 仍是String类型。 System.out.println("end"); } }
The text was updated successfully, but these errors were encountered:
fix toJavaObject map field generic keyType not work, for issue #1269
e2bfebe
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.27-SNAPSHOT/ 问题已修复,请帮忙用2.0.27-SNAPSHOT版本验证
Sorry, something went wrong.
https://github.com/alibaba/fastjson2/releases/tag/2.0.27 问题已修复,请用新版本
No branches or pull requests
The text was updated successfully, but these errors were encountered: