I have a webservice ready, which returns a JSON of an object, great, working: Here is the returned JSON:
{"Opa":{"nome":"Teste1234"}}
This JSOn is of the following class:
public class Opa {
public String nome = "Basico";
}
GSON simply creates the object with the null values. Code below:
GsonBuilder etaB = new GsonBuilder();
Gson pegador = etaB.create();
Opa teste1 = pegador.fromJson("{\"Opa\":{\"nome\":\"Teste1234\"}}",Opa.class);
I put the direct string in the fromJson method above to illustrate.
My problem is:
The name of the class at the beginning "Opa": {} - If I just send {"name": "Test1234"} then he can do the conversion.