Skip to content
This repository has been archived by the owner on Jun 26, 2019. It is now read-only.

java.lang.IllegalStateException: #2

Open
mohdirfan87 opened this issue Sep 9, 2018 · 5 comments
Open

java.lang.IllegalStateException: #2

mohdirfan87 opened this issue Sep 9, 2018 · 5 comments

Comments

@mohdirfan87
Copy link

I am using your live data adapter but I got error in observer callback, please look at the issue.

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $

@leonardoxh
Copy link
Owner

This is not related to the library itself it's a parse error.

Your response is expecting a object while the real response is returning an array.

@mohdirfan87
Copy link
Author

I think this api is not compatible with json array response , if it is compatible with json array response ,please give the some live of code , for your kind information i am using as:

@get("marvel")
LiveData<Resource<List>> getHeroesLiveDataList();
i think its expecting the object and the response is json array.
My question is how to deal with response of json array in case of LiveData by adding the LiveDataFactory in Retrofit library.

@leonardoxh
Copy link
Owner

I can try on the weekend.

@leonardoxh leonardoxh reopened this Sep 11, 2018
@coder966
Copy link

It was expecting object because you did
GET("marvel") LiveData<Resource<List>> getHeroesLiveDataList();

Instead, try
GET("marvel") LiveData<Resource<List<Hero>>> getHeroesLiveDataList();

List is an object, while List<Hero> is an array

Assuming Hero is your model class.

@sebargarcia
Copy link

sebargarcia commented Jun 3, 2019

I have the same error and I can´t figure out what is the error. I tried with LiveDataCallAdapter from google examples and get the same error. But If I try with Call object its works.

UPDATE: Never mind. It was my error. It is working now

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants