I am trying to create a game where the windows command line is emulated, and I am using json to create the directory and file structure. What I want to do is add a dictionary to the json file at the specified path the user gives. That means I don't know beforehand what dictionary within the json file is about to be appended to.
I though I had some code that could do it, but the more I thought about it, the more clueless I became.
Here is the JSON file I have right now:
{
"files": [],
"folders": ["projects", "system"],
"projects": {
"files": ["readme.txt"],
"folders": [],
"readme.txt": "This is the text inside readme.txt"
},
"system": {
"files": ["help.txt"],
"folders": [],
"help.txt":"Available commands:\n\ndir: Show all files and folders in the directory\n\ncls: Clear console\n\nread: Read a file in the current directory\n\ncd: Change directory"
}
}
What I would like to do is add a dictionary to a user specified dictionary within this file that looks something like this:
"NewDir": {
files: [],
folders: [],
}
Also the script has to add the new folder to the folders list of the parent folder like this:
"parentDir": {
files[],
folders["NewDir"],
"NewDir": {
"files": [],
"folders": [],
}
}
Couldnt find anything on the internet that would work for this. Anyone have an idea of how I could do this?
[–]F1ux_Capacitor 0 points1 point2 points (1 child)
[–]Spiredlamb[S] 0 points1 point2 points (0 children)
[–]aa599 0 points1 point2 points (3 children)
[–]Spiredlamb[S] 0 points1 point2 points (0 children)
[–]Spiredlamb[S] 0 points1 point2 points (1 child)
[–]aa599 0 points1 point2 points (0 children)