This is the json file:{"Type": "File", "File_Name": "tempfile.fasttext", "File_Size": 15}
i use Fastjson to deserialize it and show the items..but
public static void deserializejson(String json){
fileinfo fileinfo2 = JSON.parseObject(json, fileinfo.class);
System.out.println(fileinfo2.getfiletype());
System.out.println(fileinfo2.getFile_Name());
System.out.println(fileinfo2.getfilesize());
}
public class fileinfo {
private String File_Name;
private String Type;
private int File_Size;
public String getFile_Name(){
return File_Name;
}
public String getfiletype(){
return Type;
}
public int getfilesize(){
return File_Size;
}
}
but it didn't return what i expected , but
null
null
0
what is the problem of my code? plz forgive my bad english and Thanks again
You need the setter function, JSON needs setter to inject the values when parsing the JSON string. And all your getters' format is not right. Try with this: