Msgpack: Difference between revisions

From air
Jump to navigation Jump to search
 
Line 29: Line 29:




Avec [[Node-RED]]
=[[Node-RED]]=
pour encoder un message
<source lang="javascript">
<source lang="javascript">
context.msgpack = require('msgpack');
context.msgpack = require('msgpack');
Line 35: Line 36:
msg.payload=context.msgpack.encode(payload);
msg.payload=context.msgpack.encode(payload);
//msg.payload=context.msgpack.decode(payload);
//msg.payload=context.msgpack.decode(payload);

return msg;
</source>

pour décoder un message
<source lang="javascript">
context.msgpack = require('msgpack');

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


return msg;
return msg;

Latest revision as of 13:36, 9 November 2014

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;