I have a weird problem. So I've created an object where three of the properties of said objects are actually custom types.
So the "merchant" object has "BillingAddress", "BillingDetails", and "authorizer" as properties which are defined as classes.
When I create the object merchant and fill the constructor, the log shows that it has been made, and the 3 custom properties have a reference number. The log also shows that all 3 custom objects have been initialized correctly. (Don't worry, data is made up test data and isn't real).
However, when the serialization to JSON occurs, the API call returns a bad request. Upon investigation, it seems the JSON serialized isn't right.
It seems like the serialized version isn't even the correct JSON Format, please not the ending, it isn't even complete.
For some reason, the RegAddress (Billing Address) has serialized properly but for some reason the Billing Details and the Authorizer have completely been removed from the JSON string. Please see image below of the System.Debug printout.
As you can see it's very bizarre and have no idea why this is happening. The class structures are identical.