I’ve managed to save a JSON file, but I’m not able to read it back. The JSONReader has the following error when debugging:
Invalid Json Token. Line: 1 Ch: 1
FString FullPath = FPaths::GameSavedDir();
FullPath += "filename.json";
FArchive* SaveFile = IFileManager::Get().CreateFileReader(*FullPath);
if (!SaveFile) return;
TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(SaveFile);
//Doesn't work either
//TSharedRef<TJsonReader<>> JsonReader = TJsonReaderFactory<>::Create(SaveFile);
//JSON Reader has error message after this line
const bool ds = FJsonSerializer::Deserialize(JsonReader, JsonObject); //Returns false
if (JsonObject.IsValid())
{
//Returns true
}
Also http://jsonlint.com/ confirms that the saved JSON is valid.
Any and all help is very much appreciated.
Thanks
Edit: Here’s the JSON file
[
{
"Name": "a",
"BC": 0,
"LN": 121.45,
"RT": 1.47197,
"SC": 1
},
{
"Name": "b",
"BC": 0,
"LN": 138.924,
"RT": 1.03696,
"SC": 1
},
{
"Name": "c",
"BC": 0,
"LN": 167.129,
"RT": 1.38207,
"SC": 1
},
{
"Name": "d",
"BC": 1,
"LN": 195.074,
"RT": 0.98531,
"SC": 1
},
{
"Name": "e",
"BC": 0,
"LN": 138.697,
"RT": 0.873527,
"SC": 1
},
{
"Name": "f",
"BC": 0,
"LN": 110.974,
"RT": 2.22515,
"SC": 1
},
{
"Name": "g",
"BC": 0,
"LN": 120.026,
"RT": 0.663795,
"SC": 1
}
]