Note that there are some explanatory texts on larger screens.

plurals
  1. POMsgPack packing of string values longer than 32 characters in python
    text
    copied!<p>I'm using MessagePack for developing a client SDK. I need to develop clients in java, ObjC and python while my server is in java. I don't have any problems with java and ObjC msgpack libraries but in python, when I pack a dictionary with string value longer than 31 characters, the packed data won't unpack in other languages. Trying to unpack the same in python works fine though and as long as the string length is less than 32, the inter operability is very fine too. The below is one python example that fails..</p> <pre><code>myPacket = {u"api_key":u"ad09739ac168ff2a199fb24eb4e24db8"} msgPackedPacket = umsgpack.packb(myPacket) </code></pre> <p>the binary data generated for this is </p> <pre><code>&lt;81a76170 695f6b65 79d92061 64303937 33396163 31363866 66326131 39396662 32346562 34653234 646238&gt; </code></pre> <p>while if I covert a dictionary with same key values in ObjC, I get </p> <pre><code>&lt;81a76170 695f6b65 79da0020 61643039 37333961 63313638 66663261 31393966 62323465 62346532 34646238&gt; </code></pre> <p>The ObjC result unpacks fine and the python won't.. and you can note the 2 extra bytes in data from ObjC.</p> <p>A properly working example as below</p> <pre><code>myPacket = {u"api_key":u"ad09739ac168ff2a199fb24eb4e24d"} </code></pre> <p>number of characters = 30 here.. and I get the following bytes in python </p> <pre><code>&lt;81a76170 695f6b65 79be6164 30393733 39616331 36386666 32613139 39666232 34656234 65323464&gt; </code></pre> <p>and for ObjC, I get the below bytes..</p> <pre><code>&lt;81a76170 695f6b65 79be6164 30393733 39616331 36386666 32613139 39666232 34656234 65323464&gt; </code></pre> <p>I'm sorry if I miss something obvious.. looking for any workarounds or suggestions as I am struck for more than a day..</p> <p>Thanks in advance. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload