I am sending the list of record details in JSON format to apex controller. When i am de-serializing the JSON string if the payload contains date field having some value then it is not getting deserialized:

System.JSONException: Invalid format: "6/5/2020" is malformed at "/5/2020" at [line:1, column:90]

enter image description here

apex controller :

   //update product line items data
public static string updateData(String strfromle, Id oppId){
    String returnresponse ='';
    OpportunityProduct__c opp;
    system.debug('strfromle update==>'+strfromle);
    List<OpportunityProduct__c> oppProductsListToUpdate = new List<OpportunityProduct__c>();
    List<fieldWrapper> datalist = (List<fieldWrapper>)JSON.deserialize(strfromle, List<fieldWrapper>.class);
    system.debug('datalist upload==>'+datalist);
    for(fieldWrapper wrapper : datalist){ 
      opp = new  OpportunityProduct__c();
      opp.Id = wrapper.Id;
      opp.Quantity__c = wrapper.Quantity;
      opp.UnitPrice__c = wrapper.OpportunityPrice;
      opp.StartOfDelivery__c = wrapper.StartOfDelivery;
      opp.EndOfDelivery__c = wrapper.EndOfDelivery;

    system.debug('oppProductsListToUpdate upload==>'+oppProductsListToUpdate);
    if(oppProductsListToUpdate.size() > 0){
        try {
            system.debug('entered to try insert block');
            Update oppProductsListToUpdate;
            returnresponse = 'SUCCESS';
        catch(Exception ex){
            returnresponse = 'ERROR';
    return returnresponse;
public class fieldWrapper{               
    public String EAN10;
    public String Id;
    public Decimal Quantity;
    public Decimal OpportunityPrice;
    public Date StartOfDelivery;
    public Date EndOfDelivery;


Could you please help me how can i rectify this error.

  • If you deserialize into a Date type, input must be yyyy-mm-dd; if your input is not in that form, deserialize into a String type and parse it later into a Date (which will require knowing the input locale) – cropredy Jun 3 '20 at 5:20

Browse other questions tagged or ask your own question.