Is it possible to deserialize AggregateResults? If not, why?
When I try it the regular way, all my aggregate results are empty:
List<AggregateResult> arList = [SELECT Name FROM Account GROUP BY Name LIMIT 2];
String arJson = JSON.serialize(arList);
List<AggregateResult> result = (List<AggregateResult>)
JSON.deserialize(arJson, List<AggregateResult>.class);
System.debug(arList);
System.debug(arJson);
System.debug(result);
Result:
(AggregateResult:{Name=1}, AggregateResult:{Name=AnAccount})
[{"attributes":{"type":"AggregateResult"},"Name":"1"},{"attributes":{"type":"AggregateResult"},"Name":"AnAccount"}]
(AggregateResult:{}, AggregateResult:{})
I'm trying to avoid additional wrappers and I'm interested in the reason why it doesn't work as expected.