Reputation: 319
My script stores serialized arrays in text files, but I would like to be able to split the files up in sections and store data within those sections. I have though about using text as separation, and then use substring to get data between two substrings in the file, but is there a better way (faster, easier, more reliable etc...)?
Like this:
Data set 1
-------------
Data set 2
------------
Data set 3
The only problem is that one of the data sets(serialized arrays) might contain the text used as splitpoints...
Upvotes: 0
Views: 117
Reputation:
How about storing those in JSON format? You could have a top level object representing an array of data sets or simply a list of name/value pairs like in the example bellow. Advantage of such approach would be that you have a bunch of parsers which can be used for reading/writing JSON.
Example:
{
"data_set_1" : "serialized array data for data set 1",
"data_set_2" : "serialized array data for data set 2",
"data_set_3" : "serialized array data for data set 3"
}
Upvotes: 3