这几天一直都在写LitJson的读和写,天知道我经历了什么
首先如果有这个错:
1,(JsonException: Max allowed object depth reached while trying to export from type System.Single
LitJson.JsonMapper.WriteValue (System.Object obj, LitJson.JsonWriter writer, Boolean writer_is_private, Int32 depth))
需要注意:你写入LitJson不能有float类型。LitJson的支持类型是int,double , string等类型。
2,(MissingMethodException: Method not found: ‘Default constructor not found…ctor() of clothesSave’.
System.Activator.CreateInstance (System.Type type, Boolean nonPublic) (at)
需要注意:找不到构造函数了,例如
public class clothesSave
{
public clothesSave(string Name , int ow)
{
clothName = Name;
owner = ow;
}
//服装的加载名字
public string clothName;
//是否拥有该服装(1是有,0 是没有)
public int owner;
}
修改:
public class clothesSave
{
//添加
public clothesSave(){};
public clothesSave(string Name , int ow)
{
clothName = Name;
owner = ow;
}
//服装的加载名字
public string clothName;
//是否拥有该服装(1是有,0 是没有)
public int owner;
}