JAVA Json 转 DTO 报错:Expected a string but was BEGIN_OBJECT at line 1 column 352
UserDTO user=gson.fromJson(dataJson, UserDTO.class );
由于DTO 中有date类型的变量,所以需要在builder指定格式。如:
Gson gson = (new GsonBuilder()).setDateFormat("dd/MM/yyyy HH:mm:ss").create();
UserDTO user=gson.fromJson(dataJson, UserDTO.class );
来源:CSDN
作者:LuoJianXing
链接:https://blog.csdn.net/qq_32894331/article/details/104054089