You need to sign in to do that
Don't have an account?
Kunal Purohit 4
How to map json in case of reserved keyword?
Hello Team,
i am writing Webservice and want to map json.But in debug log shows status ""For input string: "" at [line:1, column:218]..
Here is Json Response:
invoice":{"id":2651,"number":"In-151","poNumber":""}
Here is the code:
i am writing Webservice and want to map json.But in debug log shows status ""For input string: "" at [line:1, column:218]..
Here is Json Response:
invoice":{"id":2651,"number":"In-151","poNumber":""}
Here is the code:
@RestResource(urlMapping='/Invoice/*') global class GetInvoiceFromTeamWork { @HttpPost global static void doPost() { RestRequest req = RestContext.request; String jsonresponse = req.requestBody.toString(); system.debug('jsonresponse'+jsonresponse); wrapperofInvoice wrapinvoice=(wrapperofInvoice)JSON.deserialize(jsonresponse, wrapperofInvoice.class); TW_Invoice__c inv =new TW_Invoice__c(); inv.TW_Invoice_ID__c=wrapinvoice.invoice.id; //inv.TW_PO_Number__c=wrapinvoice.invoice.poNumber; insert inv; } public class wrapperofInvoice{ public eventCreator eventCreator; public Invoice invoice; } public class eventCreator { public String wholeJson; } public class invoice{ Public integer id; public integer number; public decimal poNumber; public String description; public String Status; public String currencyCode; public String dateCreated; } }
In your JSON, if it appears as a Decimal value you might want to change your code
I recommend reviewing this post as a reference
Let me know if this helps, if it does, please close the query by marking it as solved. It may help others in the community. Thank You!