Questions tagged [msgpack]

MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.

MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.

Typical small integer (like flags or error code) is saved only in 1 byte, and typical short string only needs 1 byte except the length of the string itself. [1,2,3] (3 elements array) is serialized in 4 bytes using MessagePack as follows:

> require 'msgpack'
> msg = [1,2,3].to_msgpack  #=> "\x93\x01\x02\x03"
> MessagePack.unpack(msg)   #=> [1,2,3]

Scalable RPC

MessagePack-RPC is cross-language RPC library for client, server and cluster applications. Because it releases you from complicated network programming completely and provides well-designed API, you can easily implement advanced network applications with MessagePack-RPC.

require 'msgpack/rpc'
class MyHandler
  def add(x,y) return x+y end
end
svr = MessagePack::RPC::Server.new
svr.listen('0.0.0.0', 18800, MyHandler.new)
svr.run

require 'msgpack/rpc'
c = MessagePack::RPC::Client.new('127.0.0.1',18800)
result = c.call(:add, 1, 2)  #=> 3

MessagePack is available for many languages:

  • C
  • C++
  • D
  • Erlang
  • Go
  • Haskell
  • Java
  • OCaml
  • Python
  • Perl
  • PHP
  • Ruby
  • Scala
409 questions
5
votes
2 answers

Deserializing a heterogeneous map with MessagePack in C++

I’m using MessagePack with C++ and I’m trying to deserialize the equivalent of this Python map: {'metadata': {'date': '2014-06-25', 'user_id': 501}, 'values': [3.0, 4.0, 5.0], 'version': 1} The top-level object is a map with string keys, but the…
bdesham
  • 15,430
  • 13
  • 79
  • 123
5
votes
0 answers

MessagePack and Subclasses deserialization

I am playing around with MessagePack and Java. I have had experience with Protobuf and Json (using Jackson and Gson) in the past when it comes to serialization tools. When it comes to normal serialization and deserialization I have no problems at…
le-doude
  • 3,345
  • 2
  • 25
  • 55
5
votes
1 answer

Using MSGPACK_DEFINE without changing class declarations

Is there a way in MsgPack C++ to use MSGPACK_DEFINE without altering the class members? We'd like to keep message pack stuff out of the headers, and only use it internally in a library. It seems like just wrapping each class would work, but am…
Noah Watkins
  • 5,446
  • 3
  • 34
  • 47
5
votes
2 answers

MessagePack slower than native node.js JSON

I just installed node-msgpack and tested it against native JSON. MessagePack is much slower. Anyone know why? Using the authors' own benchmark... node ~/node_modules/msgpack/bench.js msgpack pack: 4165 ms msgpack unpack: 1589 ms json pack: …
Brian Carlson
  • 61
  • 1
  • 3
5
votes
1 answer

Encoding MessagePack objects containing Node.js Buffers

I'm using node-msgpack to encode and decode messages passed around between machines. One thing I'd like to be able to do is wrap raw Buffer data in an object and encode that with Messagepack. msgpack = require('msgpack') buf =
matehat
  • 5,214
  • 2
  • 29
  • 40
5
votes
1 answer

Storing a MessagePacked hash in Redis

I'm having a problem storing a MessagePacked hash in Redis. I've pasted a test case below. When pulling out the packed data from Redis and unpacking it, the hash is slightly corrupted. This appears to happen when the hash values are beyond a…
Evan Pon
  • 1,496
  • 1
  • 13
  • 22
4
votes
2 answers

Can msgpack pack a user-defined object in C#, send the pack to a C++ app where it is then unpacked?

I have a C# reply server that can pack an object and send it to a requester C# client. Can I do the same thing, but with a C# reply server communicating with a C++ requester client? Here's an example of my C# reply server: using System; using…
EhevuTov
  • 20,205
  • 16
  • 66
  • 71
4
votes
2 answers

Mismatched free()/delete in MsgPack

I try to use Msgpack in my program. Can someone help me with next example (Streaming feature) from msgpack wiki: http://wiki.msgpack.org/pages/viewpage.action?pageId=1081387 and provide more correct example of using this library with streaming…
4
votes
1 answer

Fetch YAML or MsgPack in Javascript (Browser)

I know how to fetch JSON with the Fetch API like this: fetch('http://example.com/movies.json') .then(response => response.json()) .then(data => console.log(data)); I tried to replicate the same thing to get MsgPack or YAML data, but all my…
Mig
  • 662
  • 4
  • 13
4
votes
0 answers

c# MessagePack-CSharp getting MessagePackDynamicObjectResolverException: can't find matched constructor. type:System.String

I am trying to implement messagepack lib in my project to serialize and deserialize the POCO objects to be store in Redis however getting below exception: MessagePackDynamicObjectResolverException: can't find matched constructor.…
Amit Singh
  • 71
  • 1
  • 6
4
votes
1 answer

Fastest way to store and retrieve a large stream of small unstructured messages

I am developing an IOT application that requires me to handle many small unstructured messages (meaning that their fields can change over time - some can appear and others can disappear). These messages typically have between 2 and 15 fields, whose…
Ben
  • 317
  • 3
  • 12
4
votes
0 answers

Using Message Pack + LZ4 Compression with .NET Signalr

The Documentation Of MessagePack for C# states that using LZ4 compression you can achieve compact binary sizes of your payload. in docs you can use:enter code here var lz4Options =…
Rezga
  • 390
  • 1
  • 10
4
votes
0 answers

How can I Deserialize MessagePack from Json (via Python) with a DateTime property?

I'm trying to deserialize a MessagePack message generated from a python client to a .net object. Running into some trouble with DateTimes. Interestingly staying in the C# arena it doesn't work either. Newtonsoft is able to deserialize the json…
Brian
  • 51
  • 4
4
votes
1 answer

Invalid Type Error while using Msgpack with Flask and AngularJS

I have a simple Flask app like so: import msgpack from flask import Flask, render_template app = Flask(__name__) @app.route('/') def index(): return render_template('index.html') @app.route('/test') def test(): return msgpack.packb([1, 2,…
codemaniac
  • 879
  • 1
  • 11
  • 31
4
votes
3 answers

Error while loading spacy model AttributeError: module 'msgpack._unpacker' has no attribute 'unpack'

I have a problem while loading model for spacy 2.0.8, but the same happens for previous version 2.0.7. Do you have any ideas what's going on? Thanks in advance nlp = spacy.load('en_core_web_lg', disable=['ner']) File…
1 2
3
27 28