Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upNo ES6 Map support? #138
No ES6 Map support? #138
Comments
|
Thank you for your report. This is the specification and won't be fixed because MessagePack is designed to communicate in multi-languages. I won't add any flavors by default. However, any JavaScript programs use lots of non-primitive objects, so the MessagePack spec has extensions. Also, I'd like to add extensions to handle non-primitive objects like ES2015's Map, just like as browsers do. |
If I run the following test program with msgpack-javascript 2.1.0:
The output is:
Conclusion: Asking msgpack-javascript to encode a Map causes it to encode it as if it were an empty object.
Supporting Maps in some capacity would be good because if anything it is better to store Maps in msgpack than to store objects. Sometimes deserializing in JavaScript can cause problems or even security flaws if keys overwrite "special" javascript objects like
hasOwnPropertyor__proto__. Here is an example of such a problem. I suspect msgpack-javascript itself will not have any such security flaws, but it is easy for client code to have such security flaws and the security issues can be sidestepped by using Maps instead of objects.