You need to sign in to do that
Don't have an account?
Célio Xavier
I need help please, how do I make a template class for this Json, I've tried several ways but I'm getting the message that the Json is malformed.
My class:
Message error:
FATAL_ERROR System.JSONException: Malformed JSON: Expected '{' at the beginning of object
Fatal Erro: Malformed JSON: Expected '{' at the beginning of object
I need help please, how do I make a template class for this Json, I've tried several ways but I'm getting the message that the Json is malformed.
[ { "tipo": "PECÚLIO POR MORTE - RISCO", "beneficiarios": [ { "idade": 60, "nascimento": "0000-00-00", "parentesco": "PAIS", "percentualRateio": 50, "cpf": "12312312345", "nome": "L***MASC***", "id": 3449190, "sexo": "FEMININO" }, { "idade": 38, "nascimento": "0000-01-00", "parentesco": "IRMÃO", "percentualRateio": 50, "cpf": "12312312365", "nome": "S***MASC***", "id": 3449188, "sexo": "MASCULINO" } ], "valorBeneficio": 46100.83, "valorPagamento": 79.13, "status": "SUSPENSO" }, { "tipo": "RENDA MENSAL VITALÍCIA - SOBREVIVENCIA", "idadeSaida": 65, "beneficiarios": [ { "idade": 38, "nascimento": "0000-01-00", "parentesco": "IRMÃO", "percentualRateio": 50, "cpf": "12312312378", "nome": "S***MASC***", "id": 3449188, "sexo": "MASCULINO" }, { "idade": 63, "nascimento": "0000-07-00", "parentesco": "PAIS", "percentualRateio": 50, "cpf": "12312312378", "nome": "L***MASC***", "id": 3449190, "sexo": "FEMININO" } ], "valorBeneficio": 0, "dataSaida": "2053-10-23", "valorPagamento": 0, "status": "SUSPENSO" } ]
My class:
public with sharing class ConsultationBeneficiaryModels { public class JSON2Apex { @AuraEnabled public String tipo; @AuraEnabled public Double valorBeneficio; public List<Beneficiarios> beneficiarios; @AuraEnabled public Double valorPagamento; @AuraEnabled public String status; @AuraEnabled public Integer idadeSaida; @AuraEnabled public String dataSaida; } public class Beneficiarios { @AuraEnabled public Integer idade; @AuraEnabled public String nascimento; @AuraEnabled public String parentesco; @AuraEnabled public Integer percentualRateio; @AuraEnabled public String cpf; @AuraEnabled public String nome; @AuraEnabled public Integer id; @AuraEnabled public String sexo; } }
Message error:
FATAL_ERROR System.JSONException: Malformed JSON: Expected '{' at the beginning of object
Please use below Tested Code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
I was doing this: