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
Map序列化配置WriteClassName后,反序列化会多出类型信息的entry(配置SupportAutoType也是),在fastjson 1.2.83上没有这个问题
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONWriter; import org.junit.jupiter.api.Test; import java.util.HashMap; import static org.junit.jupiter.api.Assertions.assertEquals; public class Issue336Mutated_758 { @Test public void testEmpty() { HashMap<String, String> map = new HashMap<>(); map.put("date", "2022"); String jsonString = JSON.toJSONString(map, JSONWriter.Feature.WriteClassName); // HashMap result = JSON.parseObject(jsonString, HashMap.class, JSONReader.Feature.SupportAutoType); HashMap result = JSON.parseObject(jsonString, HashMap.class); assertEquals(1, result.size()); } @Test public void testEmpty1() { HashMap<String, String> map = new HashMap<>(); map.put("date", "2022"); String jsonString = com.alibaba.fastjson.JSON.toJSONString(map, SerializerFeature.WriteClassName); HashMap result = com.alibaba.fastjson.JSON.parseObject(jsonString, HashMap.class); assertEquals(1, result.size()); } }
不含有@type -> java.util.HashMap项
@type -> java.util.HashMap
The text was updated successfully, but these errors were encountered:
WriteClassName在parse时应该和SupportAutoType配对使用,这个不是BUG
Sorry, something went wrong.
public void test() { HashMap<String, String> map = new HashMap<>(); map.put("date", "2022"); String jsonString = JSON.toJSONString(map, JSONWriter.Feature.WriteClassName); HashMap result = JSON.parseObject(jsonString, HashMap.class, JSONReader.Feature.SupportAutoType); System.out.println(JSON.toJSONString(result)); // {"date":"2022","@type":"java.util.HashMap"} assertEquals(1, result.size()); }
是配对使用的,但在parse后的map entry里面依然保留着类型信息@type -> java.util.HashMap
fix deserialize HashMap autoType not skip @type entry, for issue #2581
7ea0d82
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.51-SNAPSHOT/ 问题已修复,请帮忙用2.0.51-SNAPSHOT版本验证
验证已修复,辛苦温少
https://github.com/alibaba/fastjson2/releases/tag/2.0.51 问题已修复,请用新版本
No branches or pull requests
问题描述
Map序列化配置WriteClassName后,反序列化会多出类型信息的entry(配置SupportAutoType也是),在fastjson 1.2.83上没有这个问题
环境信息
重现步骤
期待的正确结果
不含有
@type -> java.util.HashMap
项The text was updated successfully, but these errors were encountered: