mirror of https://github.com/alibaba/fastjson2.git
fix Set deserialize error, for issue #1417
This commit is contained in:
parent
08f3fa62f3
commit
76415d5149
|
|
@ -1927,6 +1927,13 @@ public abstract class JSONReader
|
|||
} else {
|
||||
throw new JSONException(info("illegal input " + ch));
|
||||
}
|
||||
case 'S':
|
||||
if (nextIfSet()) {
|
||||
val = read(Set.class);
|
||||
break;
|
||||
} else {
|
||||
throw new JSONException(info("illegal input " + ch));
|
||||
}
|
||||
default:
|
||||
throw new JSONException(info("illegal input " + ch));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.alibaba.fastjson2.issues_1000;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONReader;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class Issue1417 {
|
||||
@Test
|
||||
public void test() {
|
||||
String str = "{\"value\":Set[1]}";
|
||||
JSONReader jsonReader = JSONReader.of(str);
|
||||
Map<String, Object> object = jsonReader.readObject();
|
||||
Set value = (Set) object.get("value");
|
||||
assertEquals("[1]", JSON.toJSONString(value));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue