U3d,解析jsondata提示错误.InvalidCastException: Instance of JsonData doesn't hold an int LitJson.JsonData.

来源:互联网 发布:中超数据库门将 编辑:程序博客网 时间:2024/06/17 04:43

在做项目的时候,需要用 jsonWriter和JsonData做数据保存.


w.WritePropertyName("mStoneLevel");
w.Write(s.mStoneLevel.ToString());

mStoneLevel是Int所以会包下面的错.

InvalidCastException: Instance of JsonData doesn't hold an int LitJson.JsonData.op_Explicit (LitJson.JsonData data)


解决方法:去到注册表,把之前用jsonWriter保存的数据删除掉,然后去掉ToString().再重新运行就好了.

原因就是本应该是int的你保存成了string型,所以解析的时候出现错误.

1 0
原创粉丝点击