Lets say I want to store user preferences, but they aren’t just string and integer preferences. Some of them are say java objects such as Color, JFreeChart chart settings, etc. What is the best way to do that? Would YAML be an option and just serialize that data into the application? I want to avoid having to write translation code converting strings into java objects. Thanks.
Share
An option is to use XStream.
It’s easy to use, needs no external config* and converts Java objects to/from XML or JSON.
*If you want to make the serialized preferences more portable or readable, you will need a couple of annotations. But if the objective is just to serialize/deserialize Java objects into/from a roughly human-readable format, you don’t even need annotations.