I need to serialize a bunch of non-primitive types. How would I do this?
I'm using JsonSerializer.serializeToUtf8Bytes
I need to serialize a class that contains a bitmap, and some custom classes with properties
7 Replies
Basically I need to serialize the Bitmap and the properties of the other classes
depending on your usecase you could serialize the raw bitmap data as base64 perhaps
I'm using avalonia ui right now. But the thing is I've used Unity a few times, and I woud just apply the ISerializable interface and instruct how to serialize and deserialize. Cant i do that with jsonserializer?
I dont remember if the ISerializable was part or not of the unity ecossystem actually...
depends which you're using, most offer the ability to provide custom serialisers for specific types
How to write custom converters for JSON serialization - .NET
Learn how to create custom converters for the JSON serialization classes that are provided in the System.Text.Json namespace.
should be a simple case of writing a converter for bitmap which converts to/from base64 or raw bytes, whatever you fancy
Thanks, i also have an enumerable of an interface that have other types to, idk how to do this