[Unity] Update basic json validity check.

This commit is contained in:
John 2016-05-13 13:03:33 +08:00
parent e5b36f4180
commit 0b00800e39

View File

@ -711,21 +711,26 @@ namespace Spine.Unity.Editor {
try {
obj = Json.Deserialize(new StringReader(asset.text));
} catch (System.Exception) {
}
if (obj == null) {
Debug.LogError("Is not valid JSON");
return false;
}
Dictionary<string, object> root = (Dictionary<string, object>)obj;
var root = obj as Dictionary<string, object>;
if (root == null) {
Debug.LogError("Parser returned an incorrect type.");
return false;
}
if (!root.ContainsKey("skeleton"))
return false;
Dictionary<string, object> skeletonInfo = (Dictionary<string, object>)root["skeleton"];
string spineVersion = (string)skeletonInfo["spine"];
//TODO: reject old versions
// var skeletonInfo = (Dictionary<string, object>)root["skeleton"];
// string spineVersion = (string)skeletonInfo["spine"];
// TODO: Warn users of old version incompatibility.
return true;
}