In the platform event, I only see custom field datatypes with Text, Date, Checkbox and Number, but not an sobject type. I need to serialize my own class instance (which has accounts + contact list) and publish the object in json format.
I tried creating a custom text field (with name data__c) and assigned the json serialized object to this field. But, the receiver side is getting the unnecessary quote since it's a string. I want to avoid that and just publish as an object only, can I do that? Now, at the receiver side the data__c is coming like start and ends with double quotes instead of just an object (which starts with curly brackets) like as follows:
So, one option is the receiver should take these quotes out and treat this as an object or other option sending it like an object itself. Request is, can we send as an object? Please help me here.
Thanks
// custom classes defined for json serialization
class CustomAccount {
String oper;
List<Account> accountList;
List<CustomContact> custContactList;
}
// creating an object customAccount ca = new CustomAccount();
// My new platform event, with assigning the json serialized data to data__c which a text field Pltf_Notifications__e eve = new Pltf_Notifications__e();
eve.data__c = json.serialize(ca); enter code here