string text = File.ReadAllText(settingsFolder + "myFile.json");
dynamic myObject = JsonUtility.FromJson<string>(text);
Debug.Log(myObject);
Results in:
System.Dynamic.UpdateDelegates:UpdateAndExecuteVoid2(CallSite, Type, Object)
UnityInterface:Start() (at Assets/Scripts/Core/UnityInterface.cs:72)
But it has an empty line above it, it’s not null, it’s an empty string.
myFile.json, entirely copypasted:
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
It’s just an example I copied from the Internet.
I expected a Dictionary, List or some form of JSON class. Instead I’ve got an empty string (not null). Link to ReadAllText is correct, otherwise (as tested) it would’ve thrown: DirectoryNotFoundException: Could not find a part of the path.
I can’t work with “NewtonSoft” thing because I already installed it and Visual Studio still tells me that such namespace doesn’t exist.
There’s also another thing which had “Web” in it’s namespace that had the same issue. I installed it, but it still wouldn’t budge.
Solutions were to include it in the solution by going through dependencies, which I’ve done, still no budge.
How do I put items in and out of JSON string?