Is there any easy way to convert JSON data into a class and to convert the elements of a class into JSON data? I ask because I find it much easier working with classes rather than JSONitems within my code, but I’d like to save the class data using JSON. dotNet has a serialization class which does this kind of thing, but I haven’t seen any easy way to doing it in Xojo.
For this situation I use a sub class of a JSONItem, with computed properties as a means of interacting with the properties of the class, but all the data is stored within the JSONItem.
Introspection can certainly be used to serialize and deserialize your classes to/from JSON, and yes, Kem has a class for that. He did a session on Serialization at XDC this year about it.
For simple classes, using Introspection isn’t that hard. When they get to be more complex, it’ll take quite a bit more work but once you have the framework written, it’ll be a huge time saver. I did a webinar on Introspection that went over the basics Introspection and one of the examples we went through was serializing and deserializing your objects via JSON if you wanna get started with something, keeping in mind it’s for simple classes.