One colleague and I spend a few mins wondering why a class constructor was not called when Salesforce was reconstructing the class using JSON.deserialize(jsonString, apexType)
. I could not find any documentation that specifies that, but I expected the no-arg constructor to be called.
The deserialized class was something like this:
public class MyType {
public String config;
public final String defaultConfig;
public MyType() {
defaultConfig = 'anyValue';
}
public void calculate() {
if (String.isEmpty(config)) config = defaultConfig;
...
}
}
So, is this expected behaviour, or is this an extraneous versioned behaviour?