how to parse an array without root
opened this issue · comments
I couldn't parse a json array without root like below api. If I add a root as Mock data, I can do it easily but no root, no response :D Is it possible to do it thanks to Wasp?
http://api.goeuro.com/api/v2/position/suggest/de/izmir
This should work out of box actually, have you tried with List interface?
List<YourType> list = request.execute();
or async/rx
how did you define your end points?
I couldnt understand what you mean with List interface. I tried it with mock data by adding jsonobject like { goEuroList:[bla bla]}. However, how can I write a response class according to given json?
List < MyModelClass > ____; what should be blank? Do you have any idea?
I defined my endpoints like below.
@get("/{term}")
void goEuro(@path("term") String term, Callback < GoEuroResponse > callback);
waspService = new Wasp.Builder(this)
.setEndpoint("http://api.goeuro.com/api/v2/position/suggest/de")
.enableCookies(CookiePolicy.ACCEPT_ALL)
.setLogLevel(LogLevel.FULL)
.setNetworkMode(NetworkMode.LIVE)
.build()
.create(WaspService.class);
The endpoint returns list, thus callback should have List as well. If you try like below, I think the problem will be solved :)
@GET("/{term}")
void goEuro(@Path("term") String term, Callback<List<GoEuroResponse>> callback);
It's done, thank you so much for your time and interest :)
👍