1
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 null values. Code below:
GsonBuilder etaB = new GsonBuilder();
Gson pegador = etaB.create();
Opa teste1 = pegador.fromJson("{\"Opa\":{\"nome\":\"Teste1234\"}}",Opa.class);
I put the string directly in the fromJson method above to illustrate.
My problem is:
The class name at the beginning "Opa":{} - If I send only {"name":"Teste1234"} then it can do the conversion.
What language are you using? If yes see http://blog.wektabyte.com/converter-objetos-java-em-json-e-vice-versa-com-gson/
– Marconi