Giter VIP home page Giter VIP logo

cshape-dxvalue's Introduction

cshape-dxvalue

C#版本的msgpack库 编码用法如下:

        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);
        }

parse

        System.IO.FileStream stream = new System.IO.FileStream("d:\\1.bin", System.IO.FileMode.Open);
        DxMsgPack.DxMsgPack.Decoder decoder = new DxMsgPack.DxMsgPack.Decoder(stream);
        stream.Close();
        DxValue.DxRecordValue bv = (DxValue.DxRecordValue)decoder.Parser();
        DxValue.DxRecordValue test = bv.ForcePathRecord("code.data");
        Debug.Log(bv.AsString);

map

        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"));

array

        DxValue.DxArrayValue arr = new DxValue.DxArrayValue();
        for(int i = 0; i < 5; i++)
        {
            arr.SetString(-1, "asdf");
        }
        Debug.Log(arr.AsString);

cshape-dxvalue's People

Contributors

suiyunonghen avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.