1

I have read on various sites that Msgpack is JSON compatible? What does that really mean? Example of this claim: 1) https://stackoverflow.com/a/6357042/64758 2) http://blog.andrewvc.com/why-arent-you-using-messagepack

If I have the following json (written using json.org java library); how would one write that in MsgPack

    JSONObject obj = new JSONObject();
    obj.put("key1", "value1");
    obj.put("key2", "value2");

{"key1":"value1","key2":"value2"}

How would one write similar using Msgpack? I dont see a concept of 'key/value' pairing in there

Community
  • 1
  • 1
shergill
  • 3,738
  • 10
  • 41
  • 50

1 Answers1

0

I'm not 100% sure what you mean by "JSON compatible". Msgpack is a binary serialization format, and could not be decoded using any kind of "json_decode()" type functions. It is its own specification. This post highlights some of the differences and alternative choices.

Performant Entity Serialization: BSON vs MessagePack (vs JSON)

Community
  • 1
  • 1
  • Read the first bullet here: http://blog.andrewvc.com/why-arent-you-using-messagepack – shergill May 29 '13 at 18:57
  • Also read the first point by the author here: http://stackoverflow.com/a/6357042/64758 – shergill May 29 '13 at 18:59
  • It seems like they're saying that JSON and Msgpack will both work on the same data. So if you decoded a JSON array, you could immediately encode to Msgpack. However, as stated in your second link, BSON has special types like "ObjectId", "Min key", "UUID" or "MD5" ... These types are not compatible with JSON. So the two don't play nice. – Russell_Rollins May 29 '13 at 19:36