Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | iris |
I’m trying to make a script that reads JSON files and edits variables if a specific key inside of the JSON file != null. When the key != null, it’s a dictionary with a few arrays inside of it, with extra keys that I use to specify what I want to change.
[{"Text" : "This is what the JSON looks like", "Options" : null},
{"Text" : "This is what the file looks like when I want to edit options", "Options" : [{"Option1" : "Random value"}, {"Option2" : "Value2"}]}]
This way, if the player picks an option, I can set up the appropriate variable change inside of the JSON so that everything can be handled in one script .
The issue that I’m running into is that the script can read the normal array (example 1) just fine, but when I isolate the “Options” key to read it’s values;
if json_data.Options != null:
var player_options = json_data.Options
parameter1 = player_options.Option1
I get an invalid get index error no matter what.
Invalid get index ‘option1’ (on base: ‘Dictionary’).
I’m really new to coding and working with this sort of thing, any insight would be appreciated.