Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 492

今天遇上了Gson解析的BUG,卡了几个小时,急疯了最后找到原因了,最后发现下面两个json 的schedule字段一个是[] 一个是{}


保错

Exception in thread "main" com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 492

at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
at com.google.gson.Gson.fromJson(Gson.java:795)
at com.google.gson.Gson.fromJson(Gson.java:761)
at com.google.gson.Gson.fromJson(Gson.java:710)
at com.google.gson.Gson.fromJson(Gson.java:682)
at test.AATT.main(AATT.java:24)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 492
at com.google.gson.stream.JsonReader.expect(JsonReader.java:339)
at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:322)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:165)

... 9 more



解析的字符串


{

  • status"success",
  • result
    {
    • id141,
    • car_wash_id141,
    • status1,
    • license_plate_number"TYYUuui",
    • user_id38,
    • paid_client0,
    • paid_server0,
    • cancel_reason"",
    • score0,
    • price20,
    • comment"",
    • updated_at"2014-12-26 16:50:15",
    • icon_link" http://img.xqafu.com/img/475303a1537be04672282ca50734e485%4080w_80h_100Q_3x.png?OSSAccessKeyId=N0FYKF5G08bdN8Qi&Expires=4070880000&Signature=nAvVP94VaWDwp1yQAUGGK5fS1aI%3D ",
    • car_location
      {
      • car_location
        {
        • car_location_id7,
        • location_name"1号楼旁边"
        }
      },
    • schedule
      {
      • schedule_id13,
      • reservation_start"2014-12-26 08:00:00",
      • reservation_end"2014-12-27 04:00:00",
      • work_start"2014-12-27 06:30:00",
      • work_end"2014-12-27 07:30:00",
      • status1
      },
    • source_front: [ ],
    • source_back: [ ],
    • source_comment: [ ]
    }
}



{

  • status"success",
  • result
    {
    • id5,
    • car_wash_id5,
    • status5,
    • license_plate_number"沪222222",
    • user_id3,
    • paid_client0,
    • paid_server0,
    • cancel_reason"",
    • score4,
    • price20,
    • comment" uuii",
    • updated_at"2014-12-26 16:08:42",
    • icon_link" http://img.xqafu.com/img/475303a1537be04672282ca50734e485%4080w_80h_100Q_3x.png?OSSAccessKeyId=N0FYKF5G08bdN8Qi&Expires=4070880000&Signature=nAvVP94VaWDwp1yQAUGGK5fS1aI%3D ",
    • car_location
      {
      • car_location
        {
        • car_location_id11,
        • location_name"5号楼旁边"
        }
      },
    • schedule: [ ],
    • source_front
      [
      • {
        • source_id7,
        • source_url" http://img.xqafu.com/img/90635e21a864bd5fef21341806ed36a3%4080w_80h_100Q_3x.png?OSSAccessKeyId=N0FYKF5G08bdN8Qi&Expires=4070880000&Signature=uBmtDZ8hFGJkGJV3SLJJS01TmE8%3D ",
        • source_big_url" http://img.xqafu.com/img/90635e21a864bd5fef21341806ed36a3%40320w_100Q_3x.png?OSSAccessKeyId=N0FYKF5G08bdN8Qi&Expires=4070880000&Signature=C5Aer5fsA%2BGLrebHuMbk0KCx6SM%3D "
        },
      • {
        • source_id8,
        • source_url" http://img.xqafu.com/img/e8b7195424b588fa6c59fdcb5d74516b%4080w_80h_100Q_3x.png?OSSAccessKeyId=N0FYKF5G08bdN8Qi&Expires=4070880000&Signature=JtYxXr3YD4mHoF5psNKpp6G9%2FVM%3D ",
        • source_big_url" http://img.xqafu.com/img/e8b7195424b588fa6c59fdcb5d74516b%40320w_100Q_3x.png?OSSAccessKeyId=N0FYKF5G08bdN8Qi&Expires=4070880000&Signature=D1m6FUcpdaSUsRpi%2Fio1%2FBTTWr4%3D "
        }
      ],
    • source_back
      [
      • {
        • source_id9,
        • source_url" http://img.xqafu.com/img/43cbd5c2256b0f254e70bbaf4c903099%4080w_80h_100Q_3x.png?OSSAccessKeyId=N0FYKF5G08bdN8Qi&Expires=4070880000&Signature=QszLqK%2FE8509nz74eoIEAww4dWs%3D ",
        • source_big_url" http://img.xqafu.com/img/43cbd5c2256b0f254e70bbaf4c903099%40320w_100Q_3x.png?OSSAccessKeyId=N0FYKF5G08bdN8Qi&Expires=4070880000&Signature=93Ti0ecFXsG38cVdMwY1w6deSy8%3D "
        },
      • {
        • source_id10,
        • source_url" http://img.xqafu.com/img/43cbd5c2256b0f254e70bbaf4c903099%4080w_80h_100Q_3x.png?OSSAccessKeyId=N0FYKF5G08bdN8Qi&Expires=4070880000&Signature=QszLqK%2FE8509nz74eoIEAww4dWs%3D ",
        • source_big_url" http://img.xqafu.com/img/43cbd5c2256b0f254e70bbaf4c903099%40320w_100Q_3x.png?OSSAccessKeyId=N0FYKF5G08bdN8Qi&Expires=4070880000&Signature=93Ti0ecFXsG38cVdMwY1w6deSy8%3D "
        }
      ],
    • source_comment
      [
      • {
        • source_id55,
        • source_url" http://img.xqafu.com/img/a5eebb8742fb21fe8b4075ff50e80f06%4080w_80h_100Q_3x.png?OSSAccessKeyId=N0FYKF5G08bdN8Qi&Expires=4070880000&Signature=QfSWuYStcIAni%2FqWl4HJuXqVP%2FU%3D ",
        • source_big_url" http://img.xqafu.com/img/a5eebb8742fb21fe8b4075ff50e80f06%40320w_100Q_3x.png?OSSAccessKeyId=N0FYKF5G08bdN8Qi&Expires=4070880000&Signature=gCIufydx5GgEyKLNF0pdHKpWZjE%3D "
        }
      ]
    }
}

你可能感兴趣的:(Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 492)