diff --git a/core/src/main/java/com/alibaba/fastjson2/JSONReader.java b/core/src/main/java/com/alibaba/fastjson2/JSONReader.java index 7a972ddd4e..61b439ac87 100644 --- a/core/src/main/java/com/alibaba/fastjson2/JSONReader.java +++ b/core/src/main/java/com/alibaba/fastjson2/JSONReader.java @@ -1927,6 +1927,13 @@ public Map readObject() { } 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)); } diff --git a/core/src/test/java/com/alibaba/fastjson2/issues_1000/Issue1417.java b/core/src/test/java/com/alibaba/fastjson2/issues_1000/Issue1417.java new file mode 100644 index 0000000000..ab7a333830 --- /dev/null +++ b/core/src/test/java/com/alibaba/fastjson2/issues_1000/Issue1417.java @@ -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 object = jsonReader.readObject(); + Set value = (Set) object.get("value"); + assertEquals("[1]", JSON.toJSONString(value)); + } +}