You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static void main(String[] args) {
String json = "{"PARAMETER":{"SSRC":[null,15,null,null,null,null,null,null,null,null,null,null,null],"RUN":124}}";
Param<?> param = JSON.parseObject(json, Param.class);
JSONObject jsonBody = (JSONObject) param.getParameter();
TypeReference typeReference = new TypeReference() {
};
Object to = jsonBody.to(typeReference.getType());
System.out.println(to);
} @Getter @Setter
static class Test {
@JSONField(name = "RUN")
private Integer run;
@JSONField(name = "SSRC")
private List ssrc;
}
@Getter
@Setter
static class Param<T> {
@JSONField(name = "PARAMETER")
private T parameter;
}
fastjson2: 2.0.12
result is :
Caused by: java.lang.NullPointerException
at com.alibaba.fastjson2.reader.ObjectReaderImplList.createInstance(ObjectReaderImplList.java:176)
at com.alibaba.fastjson2.JSONArray.to(JSONArray.java:939)
at com.alibaba.fastjson2.reader.ObjectReader.createInstance(ObjectReader.java:109)
at com.alibaba.fastjson2.JSONObject.to(JSONObject.java:1141)
The text was updated successfully, but these errors were encountered:
public static void main(String[] args) {
String json = "{"PARAMETER":{"SSRC":[null,15,null,null,null,null,null,null,null,null,null,null,null],"RUN":124}}";
Param<?> param = JSON.parseObject(json, Param.class);
JSONObject jsonBody = (JSONObject) param.getParameter();
TypeReference typeReference = new TypeReference() {
};
Object to = jsonBody.to(typeReference.getType());
System.out.println(to);
}
@Getter
@Setter
static class Test {
@JSONField(name = "RUN")
private Integer run;
@JSONField(name = "SSRC")
private List ssrc;
}
fastjson2: 2.0.12
result is :
Caused by: java.lang.NullPointerException
at com.alibaba.fastjson2.reader.ObjectReaderImplList.createInstance(ObjectReaderImplList.java:176)
at com.alibaba.fastjson2.JSONArray.to(JSONArray.java:939)
at com.alibaba.fastjson2.reader.ObjectReader.createInstance(ObjectReader.java:109)
at com.alibaba.fastjson2.JSONObject.to(JSONObject.java:1141)
The text was updated successfully, but these errors were encountered: