Skip to content Skip to sidebar Skip to footer

Reading Json With Retrofit

I've got the following JSON feed: { collection_name: 'My First Collection', username: 'Alias', collection: { 1: { photo_id: 1, owner: 'Some Owner',

Solution 1:

Your JSON is not valid.

GSON is waiting for a BEGIN_ARRAY "[" after collection: because your PhotosResponse class define an array of Photo List<Photo> but found a BEGIN_OBJECT "{", it should be

{"collection_name":"My First Collection","username":"Alias","collection":[{"photo_id":1,"owner":"Some Owner","title":"Lightening McQueen","url":"http://hesp.suroot.com/elliot/muzei/public/images/randomhash1.jpg"},{"photo_id":2,"owner":"Awesome Painter","title":"Orange Plane","url":"http://hesp.suroot.com/elliot/muzei/public/images/randomhash2.jpg"}]}

maybe you get that JSON from an incorrect json_encode() PHP array with key, you should encode JSON from PHP without keys, with the array values only (PHP Array to JSON Array using json_encode())

Post a Comment for "Reading Json With Retrofit"