问题
YouTube Data API v3 search JSON response retrofit parsing error occurred
@GET("/youtube/v3/search")
void getYouTubeVideos(@Query("key") String apiKey,
@Query("channelId") String channelId,
@Query("part") String videoPart,
@Query("order") String videoOrder,
@Query("maxResults") String maxResults,
Callback<ChannelListResponse> callback);
for Callback<ChannelListResponse>
I have used
import com.google.api.services.youtube.model.ChannelListResponse
with dependency in gradle compile 'com.google.apis:google-api-services-youtube:v3-rev162-1.21.0'
but in failure method it returns error retrofit.RetrofitError: invalid value for field
plz guide me for better Thanks In advance
回答1:
I solved it by creating custom pojo class relevant to desired data because com.google.api.services.youtube.model.ChannelListResponse
is not having any @Expose
annotation nor @SerializedName()
that's why parsing is not being successful.
回答2:
I think the problem is with this line: @Query("maxResults") String,maxResults
. Check in the documentation and you will see that maxResults is not expecting a String but an unsigned integer.
来源:https://stackoverflow.com/questions/35364421/youtube-data-api-v3-search-json-response-retrofit-parsing-error