2
How do I parse a return json where I have optional fields, such as phone, the user can have more than one as residential, mobile and phone to message, in this case if the user informed the phone he lists if I have not informed he does not list any or only one or two, follows the example of a return below.
{
"transacao":{
"codigo":1,
"nome":"bruno",
"sobrenome":"richart",
"idade":28,
"endereco":{
"rua":"Avenidas das Americas",
"numero":12300,
"bairro":"Barra da Tijuca",
"cidade":"Andradina",
"uf":"rj"
},
"telefone":[
{
"tipo":"residencial",
"ddd":18,
"numero":37236207
},
{
"tipo":"celular",
"ddd":18,
"numero":972770022
}
],
"compra":{
"idproduto":23,
"descricao":"Celular Iphone",
"quantidade":1
}
}
}
When he doesn’t have a phone he doesn’t even have that key? Is that it? Do you want to know when you have that key or not?
– novic
@Virgilionovic Yes, in case the phone would be an array, it could have up to 3 phones, but the system would only do the parser if there was at least one phone.
– Bruno Richart
Possible duplicate of http://answall.com/questions/4410/received-data
– Mauro Alexandre