L
L
lukepker2021-12-28 20:24:20
Android
lukepker, 2021-12-28 20:24:20

How to submit JSON to POJO to work with Retrofit?

I'm doing a lab for uni. The task is to request the current weather from the server using retrofit and display the answer. As I understand it, for retrofit to work, you need to make a class that will have all the fields like the answer. The problem is that in all the examples that I found, the fields have a simple type, int or string, and my server responds with a complex object, where there are several fields, each field also has several fields, and so on. To simplify, it is suggested to feed this answer to the jsonschema2pojo site, and he will do everything himself, but there are a lot of settings, and I do not understand what to choose.
Can you please tell me how can I end up with this class? And is it necessary to reflect all 20-30 response fields in it at all, if in fact I need only one temperature field? Is it possible to specify in the class only the field I need?.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
Jacen11, 2021-12-28
@Jacen11

As I understand it, for retrofit to work, you need to make a class that will have all the fields like the answer.
misunderstood
Do I need to reflect all 20-30 response fields in it at all, if in fact I need only one temperature field?
not necessary
Is it possible to specify in the class only the field I need?.
could
you check it yourself?

P
Pavel, 2021-12-29
@LukyanovPA

You can use the standard tools of the Studio61cc17fda4418885842705.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question