I am using a SObject as a key and mutating it. When I try to get the map value using the sobject, I get null. However, when i serialize the value, I can see the old value stored.
Can anyone clarify on why serialization not showing null value ? Here is the lines i tried.
Account a1 = new Account(Name = 'Hello World');
Map<Account, String> mapAccount = new Map<Account, String>();
mapAccount.put(a1, 'MapString');
insert a1;
System.assert(false, mapAccount +'---'+JSON.serialize(mapAccount));
Output
Line: 5, Column: 1
System.AssertException: Assertion Failed: {Account:{Name=Hello World, Id=0012F00000ZUJW9QAP}=null}---{"Account:{Name=Hello World, Id=0012F00000ZUJW9QAP}":"MapString"}