Esempio n. 1
0
    void btnEncodeClick()
    {
        DxValue.DxRecordValue v = new DxValue.DxRecordValue();
        v.SetString("Name", "不得闲");
        v.SetInt("Age", 23);
        v.SetDouble("money", 234234234.234);
        v.SetDateTime("Date", System.DateTime.Now);
        DxValue.DxArrayValue arr = v.ForcePathArray("test.data");
        arr.SetString(-1, "gas"); //-1就是表示在末尾加
        arr.SetString(1, "234");
        arr.SetDateTime(4, System.DateTime.Now);
        Debug.Log(v.AsString);

        byte[] bt = v.AsMsgPackBytes;

        DxValue.DxRecordValue newValue = new DxValue.DxRecordValue();
        newValue.AsMsgPackBytes = bt;
        Debug.Log(newValue.AsString);


        DxValue.DxArrayValue arr1 = newValue.ArrayByPath("test.data");
        if (arr1 != null)
        {
            Debug.Log(arr1.AsString);

            byte[] arrybt = arr1.AsMsgPackBytes;

            arr1.Clear();
            Debug.Log(arr1.AsString);

            arr1.AsMsgPackBytes = arrybt;
            Debug.Log(arr1.AsString);
        }
    }
Esempio n. 2
0
    private void btnMapClick()
    {
        DxValue.DxRecordValue mapValue = new DxValue.DxRecordValue();
        mapValue.SetInt("code", 0);
        mapValue.SetString("msg", "消息返回成功");
        DxValue.DxArrayValue arr = mapValue.ForcePathArray("Data.Records");
        for (int i = 0; i < 4; i++)
        {
            DxValue.DxRecordValue rec = arr.NewRecord(-1);
            rec.SetString("Name", "不得闲" + i);
            rec.SetInt("Age", 35);
            rec.SetString("sex", "男");
            rec.SetDateTime("Birth", System.DateTime.Now);
            rec.SetDouble("Money", 2224495.9323);
            rec.SetString("mobile", "13129903278");
        }
        DxValue.DxRecordValue datamap = (DxValue.DxRecordValue)mapValue["Data"];
        datamap.SetString("msg", "人物信息表");
        Debug.Log(mapValue.AsString);

        Debug.Log(mapValue.GetInt("code", -1));
        arr = (DxValue.DxArrayValue)mapValue.ValueByPath("Data.Records");
        Debug.Log(((DxValue.DxRecordValue)arr[0]).GetString("Name", "test"));
    }