You need to sign in to do that
Don't have an account?

JSON deserialize
Hello everybody !!
How can I deserealize this JSON?
I have the public class TemplateDataIntegrationFieldsGATEC.InformacoesPagamentoINData and I tried to do this:
But it gives:
Thanks in advance :)
How can I deserealize this JSON?
{ "infopay": [ { "chavebanco": 4020.0, "codigocliente": "2000746", "tipotitulo": null, "valortitulo": 0.0, "datapagamento": "2021-02-20T00:00:00", "status": 4 }, { "chavebanco": 8886.0, "codigocliente": "2000466", "tipotitulo": null, "valortitulo": 0.0, "datapagamento": "2021-04-20T00:00:00", "status": 6 }, { "chavebanco": 8842.0, "codigocliente": "2000466", "tipotitulo": null, "valortitulo": 0.0, "datapagamento": "2021-04-20T00:00:00", "status": 8 }, { "chavebanco": 8887.0, "codigocliente": "2000466", "tipotitulo": null, "valortitulo": 0.0, "datapagamento": "2021-04-20T00:00:00", "status": 6 }] }
I have the public class TemplateDataIntegrationFieldsGATEC.InformacoesPagamentoINData and I tried to do this:
TemplateDataIntegrationFieldsGATEC.InformacoesPagamentoINData resp = (TemplateDataIntegrationFieldsGATEC.InformacoesPagamentoINData) JSON.deserialize(response.getBody(), TemplateDataIntegrationFieldsGATEC.InformacoesPagamentoINData.class); List<TemplateDataIntegrationFieldsGATEC.InformacoesPagamentoINData> respList = new List<TemplateDataIntegrationFieldsGATEC.InformacoesPagamentoINData>{resp}; IntegrationInboundInformacoesPagamento.upsertPaymentInfo(respList);
But it gives:
(InformacoesPagamentoINData:[chavebanco=null, codigoFazenda=null, codigocliente=null, datapagamento=null, status=null, tipotitulo=null, valortitulo=null])
Thanks in advance :)
1. Based on your JSON the wrapper class must be like below:
2. Please use the below code to deserialize:
3. I have executed the above codes and got below o/p:
Thanks,
Maharajan.C
All Answers
1. Based on your JSON the wrapper class must be like below:
2. Please use the below code to deserialize:
3. I have executed the above codes and got below o/p:
Thanks,
Maharajan.C
>> https://json2apex.herokuapp.com/
You can use the above link that converts the JSON you have to the apex class along with the test class.
The test class you can use is below:
And for future step by step you can checkout: https://www.ktema.org/2020/04/17/json-apex-intro/
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.