#Retrofit question
1 messages · Page 1 of 1 (latest)
<@&1008423204219531294> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
can you say a bit more?
are you just trying to hook into how retrofit handles json?
Well i know the basics of retrofit, i used it in 2 previous small projects.
I used it to get a json from crypto coins api for example. I would create a list of data classes with vars like name, usd value, image url etc.
Then I was able to access the json keys something like this:
View.text = cryptocoins[0].name
If you understand
So is it possible for retrofit to create this list of data classes without the api get request?
For example from a string or a json file in the project
Well I was helped by chatgpt so I will post the answer here
val jsonString = "{\"name\": \"John Doe\", \"age\": 30}"
// Create a ResponseBody object from the JSON string
val responseBody = ResponseBody.create(MediaType.parse("application/json"), jsonString)
// Use Retrofit's converter to convert the ResponseBody to a User object
val user = UserConverter().convert(responseBody)
Detected code, here are some useful tools: