“Expected BEGIN_OBJECT but was STRING at line 1 column 1”

前端 未结 14 2215
误落风尘
误落风尘 2020-11-22 01:11

I have this method:

public static Object parseStringToObject(String json) {
    String Object = json;
    Gson gson = new Gson();
    Object objects = gson.f         


        
14条回答
  •  旧巷少年郎
    2020-11-22 01:54

    Don't forget to convert your object into Json first using Gson()

      val fromUserJson = Gson().toJson(notificationRequest.fromUser)
    

    Then you can easily convert it back into an object using this awesome library

          val fromUser = Gson().fromJson(fromUserJson, User::class.java)
    

提交回复
热议问题