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
2
votes
3 answers

Read Binary file using MsgPack in C++

I want to read a binary file using Cpp, and its type is using MsgPack. I'm not familiar with MsgPack and I try to read binary file fist and push in MsgPack. It doesn't work. It just gets the first number again and again. Can anyone help? Thanks a…
2
votes
1 answer

What and When needs to be cleaned up when using msgpack-c?

I am using Msgpack-c. One thing that is not clear to me, is how to correctly handle memory when using this library. The quickstart examples declare everything locally and I presume rely on destructors being called when the application ends, but I…
sebf
  • 2,831
  • 5
  • 32
  • 50
2
votes
1 answer

MsgPack Serialize a JsonObject in Android

I have a JsonObject that contains several JsonArrays: { "key1" : [[1, 2, 3, 4]], "key2" : [[1, 2, 3, 4]] } I would like to pack it using MessagePack without using the JsonObjects string representation, So far i haven't found any…
2
votes
1 answer

Serialize c# object using MsgPack instead of Json using MsgPack Cli

I'm trying to acheive a kind of JSON serialization using MsgPack in c# I'm using MsggPack CLI you can find on https://github.com/msgpack/msgpack-cli According msgpack.org Documentation, serialize the model {"model":"message"} give in hexa 81 a5 6d…
user996758
2
votes
1 answer

msgpack to pack structures

I have the following structure (among many others) and I want to send it over a socket. struct Position { float x; // position selon x float y; // position selon y float theta; // orientation % z Position (float x_, float y_, float…
Vtik
  • 3,073
  • 2
  • 23
  • 38
2
votes
0 answers

universal compression and decompression

I'm building an excel plugin in .NET which is powered by django server for network calls. The plugin would make post data calls to django server and the data returned is populated in the plugin appropriately. I want to reduce the size of post data…
Krishna Deepak
  • 1,735
  • 2
  • 20
  • 31
2
votes
2 answers

Adding msgpack as content negotiation to spring mvc + boot

I'm trying to add msgpack binary dataformat as a content negotiation option. The Json and Xml works fine out of the box. I tried to add jackson msgpack mapper as a bean, like in this examle, but it does not work. When I add Accept:…
Ben
  • 3,989
  • 9
  • 48
  • 84
2
votes
1 answer

Using msgpack in C++ with variant data structures

In the question Deserializing a heterogeneous map with MessagePack in C++ an answer refers to a gist which contains an example of based on recursive boost::variant with msgpack. I am trying to replicate this with the latest msgpack-c library version…
Tim Nicholls
  • 23
  • 1
  • 5
2
votes
1 answer

MessagePack and message framing

I'm using MessagePack to encode/decode my models and send it through a TCP server. At this point, I need to define a delimiter for my messages in order to slice received buffers into correct MessagePack objects. My question is how can I define a…
Afshin Mehrabani
  • 33,262
  • 29
  • 136
  • 201
2
votes
2 answers

append new msgpack data to end of file

Is it valid to append objects to msgpack data without decoding it first? I.e something like that: encode data1 pack data1 write packed data1 to file Then, pack data2 append packed data2 to end of file or should it be: read file msgunpack file…
sivann
  • 2,083
  • 4
  • 29
  • 44
2
votes
1 answer

How to serialise msgpack over http

tl;dr: Is there an efficient way to convert a msgpack in Java and C# for transport over HTTP. I've just discovered the msgpack data format. I use JSON just about everything I send over the wire between client and server (that uses HTTP), so I'm keen…
Shane
  • 3,051
  • 3
  • 40
  • 45
2
votes
1 answer

MsgPack c++ packing a string longer than 32 characters[Ubuntu]

i want to pack a string that is larger than 32 characters but the packer returns everytime 'da'. When i use a string that contains less than 32 characters all works fine! But a larger string return only the 'da' my code looks like…
nosvad
  • 21
  • 2
2
votes
0 answers

Serializing/de-serializing with different classes using Msgpack (Java API)

I'm currently experimenting with Msgpack to de-serialize an object graph using Msgpack but I am hitting problems. At the moment I have a simple hierachy consisting of two classes: BaseMessage and PersonNew. BaseMessage has a single Long field id…
SNK
  • 51
  • 1
  • 4
2
votes
0 answers

msgpack-java & java.nio.SocketChannel

I'm having a hard time figuring out how to setup a non-blocking IO (network sockets) using msgpack. The write portion is trivial since msgpack can generate a ByteBuffer fairly easily, but I can't figure out how to do non-blocking read into the…
ruckc
  • 505
  • 1
  • 6
  • 23
2
votes
0 answers

VCR for ServiceStack's JsonServiceClient

The Ruby VCR library enables you to "Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests." I'd like to create something similar using ServiceStack's JsonServiceClient, but I…
Pauli Price
  • 4,187
  • 3
  • 34
  • 62