The documentation about the deserializeStrict
method in JSON
class is (emphasis added):
All attributes in the JSON string must be present in the specified type. If the JSON content contains attributes not present in the System.Type argument, such as a missing field or object, deserialization fails in some circumstances. When deserializing JSON content with extraneous attributes into an Apex class, this method throws an exception in all API versions. However, no exception is thrown when you use this method to deserialize JSON content into a custom object or an sObject.
I wrote this code to test it:
String jsonString = '{"first":"value1", "second":"value2", "third":"value3"}';
Account c = (Account)JSON.deserializeStrict(jsonString, Account.class);
System.debug(c);`
And I receive this exception:
Exception: System.JSONException: No such column 'first' on sobject of type Account
StackTrace: Class.System.JSON.deserializeStrict: line 19, column 1
AnonymousBlock: line 2, column 1
AnonymousBlock: line 2, column 1
LINE: 19 COLUMN: 1
Reading the documentation I understand that no exception is thrown when you use this method to deserialize JSON content into a custom object or an sObject. Is this interpretation correct or not?