Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

json2msgpack and msgpack2json fixed #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/json2msgpack
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// Read JSON data from stdin and write MessagePack data to stdout.

var msgpack = require('msgpack');
var net = require('net');
var tty = require('tty');

var data = '';

var s = new net.Stream(0);
var s = new tty.ReadStream(0);
s.addListener('data', function(d) {
data += d;
});
s.addListener('end', function() {
s = new net.Stream(1);
s = new tty.WriteStream(1);
s.resume();

if (s.write(msgpack.pack(JSON.parse(data)))) {
Expand Down
7 changes: 3 additions & 4 deletions bin/msgpack2json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
// Read MessagePack data from stdin and write JSON data to stdout.

var msgpack = require('msgpack');
var net = require('net');
var sys = require('sys');
var tty = require('tty');

var s = new net.Stream(0);
var s = new tty.ReadStream(0);
s.addListener('data', function(b) {
sys.puts(JSON.stringify(msgpack.unpack(b)));
console.log(JSON.stringify(msgpack.unpack(b)));
});
s.resume();

Expand Down