I came up with a technique a while back which I’ve been using in multiple projects. It’s using a single string to store a list of values. Each value is prefixed with the size of the value, then the deliminator (after size) and then the data – and repeat. Using this technique means that you can store literally any type of character, without trying to exclude the use of a deliminator between the values.
Here’s a sample of such a string:
23|This is the first value13|Another value5|third
That translates to a list of these values:
- This is the first value
- Another value
- third
I’ve learned by testing that this method (along with my functions to convert between this string and either an array or string list) is very fast while keeping minimal memory. It’s also very useful for sending data packets (which is where I first came up with this method).
Is there a technical name for this? Parsing is too broad of a word in this case, there must be a more specific term.
Of standard/established types of serialization, the closest that I’m familiar with is type-length-value (TLV) encoding, which differs from your scheme in that it supports the use of non-fixed types, whereas yours would require the type of each field to be known in advance (and indeed, you seem to use only strings, in all fields).