问题描述
简要描述您碰到的问题。
序列化ElementNSImpl时导致StackOverflow
com.alibaba.fastjson2.JSONException: level too large : 2049
fastjson1中有相同的issue: alibaba/fastjson#1939
fastjson1在1.2.49版本中已修复: https://github.com/alibaba/fastjson/releases/tag/1.2.49
环境信息
请填写以下信息:
- JDK信息: [e.g.:Openjdk 21]
- 版本信息:[e.g.:Fastjson2 2.0.60]
重现步骤
如何操作可以重现该问题:
- 运行下面的main方法, jdk8需将jakarta改为javax
- 出现
Exception in thread "main" com.alibaba.fastjson2.JSONException: level too large : 2049 错误
//可在此输入示例代码
import com.alibaba.fastjson2.JSON;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.annotation.*;
import java.io.Serializable;
import java.io.StringReader;
import java.util.List;
public class StackTest {
@XmlRootElement(name = "Container")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"any"
})
public static class Container implements Serializable {
@XmlAnyElement(lax = true)
public List<Object> any;
}
private static final String MESSAGE = "<Container>" +
"<WeightMajor measurementSystem=\"English\" unit=\"lbs\">0</WeightMajor>" +
"</Container>";
public static void main(String[] args) throws Exception {
JAXBContext context = JAXBContext.newInstance(Container.class, StackTest.class);
Container con = (Container) context.createUnmarshaller().unmarshal(new StringReader(MESSAGE));
System.out.println(JSON.toJSONString(con));
}
}
问题描述
简要描述您碰到的问题。
序列化ElementNSImpl时导致StackOverflow
com.alibaba.fastjson2.JSONException: level too large : 2049
fastjson1中有相同的issue: alibaba/fastjson#1939
fastjson1在1.2.49版本中已修复: https://github.com/alibaba/fastjson/releases/tag/1.2.49
环境信息
请填写以下信息:
重现步骤
如何操作可以重现该问题:
Exception in thread "main" com.alibaba.fastjson2.JSONException: level too large : 2049错误