![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | AuthorSan |
I would like to read dialogs from a json file:
{
"1" : {
"CharacterName" : "Niti",
"Dialog" : "I guess this is where I'll die."
},
"2" :
{
"CharacterName" : "Niti",
"Dialog" : "If I ever get to die, that is."
}
}
This is the code:
Godot.File files = new Godot.File();
files.Open("res://MyDialog/TestDialog.json", Godot.File.ModeFlags.Read);
string text = files.GetAsText();
var jsonFile = JSON.Parse(text).Result;
Dictionary<object, object> ParsedData = jsonFile as Dictionary<object, object>;
files.Close();
When I try printing json file, It the get the strings that are there in my file
GD.Print(ParsedData["1"]);
But when I print Parsed Data, I get a null reference exception