I am writing an internal encoding and decoding tool for several teams. Since the JSON package has different protocols than what we expected, we are implementing our own but would like to get some insights here.
Suppose I have a list of different data types such as: [123, true, "amazing", 123645212L]
What's the general idea of encoding and decoding the entire list, such that the list can be recovered to have its elements intact of the same types and values?
So far I have solved the partial problem of encoding and decoding a list of the same types: ["1","st","%2"]
The idea is, to attach a length as Unicode as a prefix to every string, so it will be serialized to “\x011\x02st\x02%2”
, and upon deserializing, the program will read the length first, before extracting the next "length" of characters to convert to string as the next element of a list.