encodeWithType method
Encode the provided object
to a json-formatted String, include class
name so that it can be decoded even if th class is unknown.
Implementation
String encodeWithType(Object object) {
return encode(wrapWithClassName(object));
}