Hi, I'm trying to make some sort of database with a json file. I read in the Docs that with "DynamicConfigFile["KEY1"]["KEY2"]["KEY3"]" we can go throught the nested keys of the save files but when I try to do that I get "Cannot apply indexing with [] to an expression of type 'object'" how can I fix it ?
Can't get nested paths to work with DynamicConfigFileSolved
I'm not sure were you saw that, but that doesn't appear to be right.
An example of subdirectory nesting is below, though not sure that is what you want:
An example of subdirectory nesting is below, though not sure that is what you want:
DynamicConfigFile dataFile = Interface.Oxide.DataFileSystem.GetFile("PluginName/SubPath");
Interface.Oxide.DataFileSystem.SaveDatafile("PluginName/SubPath"); In response to Wulf ():I'm not sure were you saw that, but that doesn't appear to be right.
An example of subdi...
if (dataFile["EpicCategory"]["EpicString"] != null)
{
Puts(dataFile["EpicCategory"]["EpicString"]); // Outputs: EpicValue
}There is an error in the actual doc... To get a nested key you have to put a "," between the args to go throught it like that
Puts(dataFile["EpicCategory", "EpicString"]);
and not like the doc says. (So the doc is wrong)
That would be usefull to correct that ;)
In response to Wulf ():That usage would actually be valid depending on what the dataFile variable actually is, just as if y...
Idk I just do that to get the actual dataFile
private static DataFileSystem dataFile = Interface.Oxide.DataFileSystem;
private DynamicConfigFile ArenasData = dataFile.GetDatafile("Arenas");
//So I could normally do that
string MyVar = (string)ArenasData["KeyToString1"]["KeyToString2"]; //But throws the error Here's an example of what you are looking for I believe:
DynamicConfigFile dataFile = Interface.Oxide.DataFileSystem.GetDatafile("PluginName");
Dictionary<string, string> allData = dataFile["EpicCategory"] as Dictionary<string, string>;
if (allData["EpicString"]["EpicString"] != null)
{
Puts(allData["EpicString"]["EpicString"]); // Outputs: EpicValue
} In response to Wulf ():Here's an example of what you are looking for I believe:
DynamicConfigFile dataFil...
How ok you made it into a dictionary !What if I had an other key ? Like a third one ? I have to create a dictionary onto a dictionary and instantiate a new dictionary by adding the firstkey like that ?
DynamicConfigFile dataFile = Interface.Oxide.DataFileSystem.GetDatafile("PluginName");
Dictionary> allData = dataFile["EpicCategory"] as Dictionary>;
if(!allData.Containskey("EpicCategory"))
{
allData.Add("EpicCategory", new Dictionary());
}
if (allData["EpicString"]["EpicString"]["EpicString"] != null)
{
Puts(allData["EpicString"]["EpicString"]["EpicString"]); // Outputs: EpicValue
} Yes.
var depthThree = new Dictionary<string, Dictionary<string, Dictionary<string, string>>> Locked automatically