玩LitJson需要注意

这几天一直都在写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;
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值