Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

share|improve this question
up vote 13 down vote accepted

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.

share|improve this answer
Making the change to Date instead of DateTime fixed it. Thanks man! – ZAR Mar 30 at 17:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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