Git Product home page Git Product logo

node-cppmsg's People

Contributors

freebugs avatar shudingbo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

node-cppmsg's Issues

发现一个小错误,在解析时,对象的名称解析错误。

1.0.2版本.node版本4.4
因需求,将原有的gb2312编码改为了utf8
依据DEMO。
调用解析时: msg.decodeMsg(buff)
{ reg: 2,
chkCode: 0,
iType: 2,
bMonitor: false,
workPath: 'no 你 wor',
processID: 1234,
subType: { mainType: 16909060, subType: 168496141 },
testint64: 52719 }

subType: { mainType: 16909060, subType: 168496141 }
正确解析应为
testObj: { mainType: 16909060, subType: 168496141 }

原因是在调用decodeObject的递归时,遗失了当前对象名。

临时解决方案
在获知是对象进行递归时,将当前key值传入。
values.push(decodeObject(buf, off, info[4],key));
设定全局key变量
this.objKey=null;//对象key
在decodeObject方法内赋值。
decodeObject(buf, offset, dsDecode,objKey)
if(objKey){
this.objKey=objKey;
}
追加data值时,判断当前value[0]是否为对象object
values[0] instanceof Object
是对象时,以全局key为相应key值。
data[this.objKey] = arrayLen <= 1 ? values[0] : values;

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.