How to customize data serialization when using ipc communicate?

Hi, I’m new to Electron, and I’d like to know how to customize data serialization when using ipc communicate?

The scene is, I what to pass a class from ipc renderer to ipc main, but every member of this class is searlized and passed. I want to customize serialization to filter or add some properties, but toJSON is not working.