Replies: 1 comment 1 reply
-
JSON-Arrays can be parsed by Gson into instances of
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So I'm trying to use Retrofit to query a server for some data through an API, and I like how much easier and more streamlined Retrofit is in making HTTP Requests, but I'm having a bit of trouble with the response. You see, for some reason the API I'm using is returning the particular data set I need as an array, like this:
[[value, value, value], [value, value, value], ...]
. So not knowing better, I initially had this set up the way you would to parse a JSON Object: created an instance of Retrofit and passed it a GsonConverterFactory, created an API interface to place the Call methods into, and created a class for the Gson converter to parse the response body into. Predictably, this causes an IllegalStateException to be thrown; and this makes sense because the converter is expecting a JSON Object and is instead being returned a JSON Array. So my question is this: I know it's possible to create a custom converter class to workaround this issue, but I'm having one heck of a time trying to figure out how to do it. There really aren't any good tutorials out there on this, so if someone has the time any examples of how this might be implemented would be very much appreciated. Thanks!Beta Was this translation helpful? Give feedback.
All reactions