Msgpack

From air
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

http://msgpack.org/

It's like JSON but fast and small.

Python

https://github.com/msgpack/msgpack-python

Javascript

https://www.npmjs.org/package/msgpack-js

>
npm install msgpack-js
node packtest.js

packtest.js

var msgpack = require('msgpack');
var assert = require('assert');

var initial = {Hello: "World"};
var encoded = msgpack.encode(initial);
var decoded = msgpack.decode(encoded);

assert.deepEqual(initial, decoded);

autre : https://github.com/msgpack/msgpack-javascript


Node-RED

pour encoder un message

context.msgpack = require('msgpack');

msg.payload=context.msgpack.encode(payload);
//msg.payload=context.msgpack.decode(payload);

return msg;

pour décoder un message

context.msgpack = require('msgpack');

msg.payload=context.msgpack.decode(payload);

return msg;