GSON throwing “Expected BEGIN_OBJECT but was BEGIN_ARRAY”?

后端 未结 10 636
暖寄归人
暖寄归人 2020-11-22 01:31

I\'m trying to parse a JSON string like this one

[
   {
      \"updated_at\":\"2012-03-02 21:06:01\",
      \"fetched_at\":\"2012-03-02 21:28:37.728840\",
           


        
10条回答
  •  一生所求
    2020-11-22 01:43

    The problem is that you are asking for an object of type ChannelSearchEnum but what you actually have is an object of type List.

    You can achieve this with:

    Type collectionType = new TypeToken>(){}.getType();
    List lcs = (List) new Gson()
                   .fromJson( jstring , collectionType);
    

提交回复
热议问题