I'm officially breaking up with Salesforce Date parsing. This has got to be the most frustrating thing.

I have the following date in a JSON string (full JSON below):


But when I try to deserialize the data:

Opportunity[] results = (List<Opportunity>)JSON.deserialize(res, List<Opportunity>.class);

I get the following error:

System.JSONException: Cannot deserialize instance of date from VALUE_STRING value 2016-12-05T16:19:44.000Z

I have looked at so many date parse issues before and from what I've gathered it must be in ISO 8601 - though ISO 8601 can take various shapes: Ruby Docs: ISO 8601

All of the following seem to recommend exactly what I've done

Cannot deserialize instance of datetime from VALUE_STRING value




How should I format this date string?

Thank you!

Full JSON string:


1 Answer 1


Three problems here:

(a) Date receiving DateTime value.

The value should be "YYYY-MM-DD" only.

(b) Decimal receiving String value.

The value should not be in quotes.

(c) You must not have a trailing comma.

JSON-compliant strings are more strict than normal JavaScript.

  • Making the change to Date instead of DateTime fixed it. Thanks man!
    – ZAR
    Mar 30, 2016 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.