Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Map null key值序例化空指针 #1503

Closed
Luckywb opened this issue Sep 29, 2017 · 1 comment
Closed

Map null key值序例化空指针 #1503

Luckywb opened this issue Sep 29, 2017 · 1 comment
Labels
Milestone

Comments

@Luckywb
Copy link

Luckywb commented Sep 29, 2017

版本1.2.38

static {
    ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
}

public static class Bean {

}

@Test
public void test() {
    Map<Long, Bean> map = new HashMap<>();
    map.put(null, new Bean());
    Map<Long, Bean> rmap = (Map<Long, Bean>) JSON.parse(JSON.toJSONString(map, SerializerFeature.WriteClassName));
    System.out.println(rmap);
}
java.lang.NullPointerException
	at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:518)
	at com.alibaba.fastjson.parser.deserializer.MapDeserializer.deserialze(MapDeserializer.java:64)
	at com.alibaba.fastjson.parser.deserializer.MapDeserializer.deserialze(MapDeserializer.java:41)
	at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:358)
	at com.alibaba.fastjson.parser.DefaultJSONParser.parse(DefaultJSONParser.java:1321)
	at com.alibaba.fastjson.parser.DefaultJSONParser.parse(DefaultJSONParser.java:1287)
	at com.alibaba.fastjson.JSON.parse(JSON.java:139)
	at com.alibaba.fastjson.JSON.parse(JSON.java:130)
	at com.yhtframework.utils.third.FastjsonUtilsTest.test(FastjsonUtilsTest.java:63)
wenshao added a commit that referenced this issue Oct 1, 2017
@wenshao wenshao added the bug label Oct 1, 2017
@wenshao wenshao added this to the 1.2.39 milestone Oct 1, 2017
@wenshao
Copy link
Member

wenshao commented Oct 1, 2017

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

@wenshao wenshao closed this as completed Oct 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants