When parsing JSON data, when using generic objects:
Public class Implements Serializable { privatestaticfinallong serialversionuid = 123L ; Private int ResultCode; Private E resultobject; Private String resultmsg; Get set}
First time in use
New Typereference<resultmsgdto<list<articledto>>>() {});
It is possible to convert the JSON string to the corresponding generic object, because I add a data, after retrieving the JSON character from the server again, when I call the method above again, this time it is not successful, but the Jsonarray type of data
The solution was then found online:
1, https://github.com/alibaba/fastjson/issues/569 there is a problem but it has been solved this time you have to look at your Fastjson jar package version, you can change a higher version of the test
2, if you change the high version or not, it is estimated that you made the same mistake as me
This time you need to look at your code, there is no use of generics and direct use of resultmsgdto, such as the following example of the error :
New Typereference<resultmsgdto>() {});
This is the time to add the generic type in the statement, even if you don't use the object he's on, but you need to add generics
Remember: the solution: Using generic types uniformly, there is no problem with resultmsgdto that do not have generic types in the project.
Reference: http://blog.csdn.net/ykdsg/article/details/50432494 thank the classmate for his selfless dedication.
Remember Fastjson generic to object the first time can turn normally, the second time becomes jsonarray problem