JsonException: 无效字符 '.'输入字符串 (Unity)
JsonException: Invalid character '.' in input string (Unity)
public string VERSION = null;
void LoadVersion()
{
#if UNITY_ANDROID
string full_path = string.Format("{0}/version", Application.streamingAssetsPath);
string jsonString;
// Android only use WWW to read file
WWW reader = new WWW(full_path);
while (!reader.isDone) { }
jsonString = reader.text;
JsonData itemData = JsonMapper.ToObject(jsonString);
#else
string path = string.Format("{0}/version", Application.streamingAssetsPath);
StreamReader reader = new StreamReader(path);
VERSION = reader.ReadToEnd().Trim();
reader.Close();
#endif
}
为了这个 json 我在这方面遇到了 6 个小时的麻烦。有人可以帮帮我吗?我不知道为什么它不起作用。
糟糕,我没有扫描项目中的所有代码,我不应该将其转换为 .json 文件。我只会读它,所以基本上我会这样做。
public string VERSION = null;
void LoadVersion()
{
#if UNITY_ANDROID
string full_path = string.Format("{0}/version", Application.streamingAssetsPath);
string jsonString;
// Android only use WWW to read file
WWW reader = new WWW(full_path);
while (!reader.isDone) { }
jsonString = reader.text;
#else
string path = string.Format("{0}/version", Application.streamingAssetsPath);
StreamReader reader = new StreamReader(path);
VERSION = reader.ReadToEnd().Trim();
reader.Close();
#endif
}
我做对了吗。我本来应该读我的 version.file
public string VERSION = null;
void LoadVersion()
{
#if UNITY_ANDROID
string full_path = string.Format("{0}/version", Application.streamingAssetsPath);
string jsonString;
// Android only use WWW to read file
WWW reader = new WWW(full_path);
while (!reader.isDone) { }
jsonString = reader.text;
JsonData itemData = JsonMapper.ToObject(jsonString);
#else
string path = string.Format("{0}/version", Application.streamingAssetsPath);
StreamReader reader = new StreamReader(path);
VERSION = reader.ReadToEnd().Trim();
reader.Close();
#endif
}
为了这个 json 我在这方面遇到了 6 个小时的麻烦。有人可以帮帮我吗?我不知道为什么它不起作用。
糟糕,我没有扫描项目中的所有代码,我不应该将其转换为 .json 文件。我只会读它,所以基本上我会这样做。
public string VERSION = null;
void LoadVersion()
{
#if UNITY_ANDROID
string full_path = string.Format("{0}/version", Application.streamingAssetsPath);
string jsonString;
// Android only use WWW to read file
WWW reader = new WWW(full_path);
while (!reader.isDone) { }
jsonString = reader.text;
#else
string path = string.Format("{0}/version", Application.streamingAssetsPath);
StreamReader reader = new StreamReader(path);
VERSION = reader.ReadToEnd().Trim();
reader.Close();
#endif
}
我做对了吗。我本来应该读我的 version.file