I have a a text file that looks like
tabs.main="******"
tabs.settings="******"
settings.setting1="******"
settings.setting2="******"
settings.setting3="******"
settings.setting4="******"
settings.setting5.title="******"
settings.setting5.settingoption1="******"
settings.setting5.settingoption2="******"
What I’d like to be able to do is parse this into a multi-leveled dictionary. For example, I’d have a root dictionary that looks like this Dictionary<string, object> and in that I would have tabs and settings which were both Dictionary<string, object> them selves. In a graphical form what I’d like is:
Dictionary<string, object>
-> Dictionary<"tabs", object>
-> Dictionary<"main", "*******">
-> Dictionary<"settings", "*******">
-> Dictionary<"settings", object>
-> Dictionary<"setting1", "*******">
And so on and so forth. Is this possible? And if so, could someone give me a pointer in the right direction.
The problem you are going to run into is that some of your keys are going to need to be stored in the dictionary with values (strings presumably) and some of them will need to be stored with Dictionaries.
In your example you listed:
These two lines contradict each other. settings.settings5 would have the key settings5 store a value in the dictionary, but the next line is expecting settings5 to be a dictionary of other values.
You could write a block of code like this:
Either way you’ll find that you will most likely want to avoid trying to creating dictionaries of dictionaries for this purpose.