JSON File
{
"values": [
"a",
"ability",
"able",
"about",
"above",
"abroad",
"absence",
"absent",
"absolute",
"accept",
"accident"
]
}
Helper Class
[System.Serializable]
public class NewUserDataFormat
{
public List<string> values { get; set; }
public NewUserDataFormat(List<string> l)
{
foreach (var VARIABLE in l)
{
values.Add(VARIABLE);
}
}
}
Parsing Method
private void LoadGameDataAsString()
{
var filePath = Application.dataPath + gameDataProjectFilePath;
if (File.Exists(filePath))
{
var dataAsJson = File.ReadAllText(filePath);
JDeserialize(dataAsJson as string);
}
else
{
Debug.Log("can't find file : " + filePath);
}
}
void JDeserialize(string jstring)
{
Debug.Log(jstring);
NewUserDataFormat sf = (NewUserDataFormat)JsonUtility.FromJson(jstring, typeof(NewUserDataFormat));
Debug.Log(sf.values.Count);//ERROR HERE
}
Please Help , Thank You in advance.
Thanks alot!
– dcmrobin