You want to serialize an object to a file, but it doesn’t implement Serializable.
The Serializable interface is annoying. It’s a basic object. Just let me read/write the object!!
One solution is very straightforward - don’t use proper “Serialization” - because it may not actually be what you need. The downside to this is that
== is not satisfied, but you probably do not need this!
Cache implemenation using this approach
This had the added complexity of dynamic file names. Given arbitrary key types, and filename length limitations, I used SHA256(json(key)).json for the filename.