Msgpack

From air
Revision as of 13:36, 9 November 2014 by Donsez (talk | contribs) (→‎Javascript)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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;