How can I convert any record
type to a single String
and back? Perhaps load the record into a stream and read it as a String? The records I'm using won't have any special types included - they're just using simple things like String
, Integer
, PChar
, DWORD
, and Array of [String]
, etc. and nothing like classes or functions.
This string will further be saved into various places, such as a flat text file, database record, sent over the network, etc. The string contents may be transferred by other means between each of these, such as copying the string from a text file and saving it to a database record. The general idea is that the string will be compatible enough to save anywhere, move it around, and load it back in to its original state. I do understand I need to be able to recognize what type of record it is and assign it accordingly, and that part I don't need help with.
You can serialize your record using the RTTI, from here you can use XML, JSON or other format to persist the record data.
If you don't want write your own method to serialize the records try these alternatives.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With