php -r 'echo strlen(json_encode(array("Hello World!")));' // 16 php -r 'echo strlen(msgpack_pack(array("Hello World!")));' // 14
php -r 'echo strlen(msgpack_pack(array("Hello World!", "Hello World!")));' // 27 php -r 'echo strlen(json_encode(array("Hello World!", "Hellow World!")));' // 32
php -r 'echo strlen(json_encode(array("Hello World!" => "Hello World!")));' // 31 php -r 'echo strlen(msgpack_pack(array("Hello World!" => "Hello World!")));' // 27
pecl install msgpack
Example for Python: pip install u-msgpack-python // easy_install u-msgpack-python
For Ruby: gem install msgpack
MessagePack::__construct(boolean $opt = null); // $opt - php.ini msgpack.php_only MessagePack::setOption(integer $option, boolean $value); // MSGPACK_CLASS_OPT_PHPONLY MessagePack::pack(mixed $value); // MessagePack::unpack(string $str, $object = null); // . , , , . MessagePack::unpacker(); // MessagePackUnpacker. , .
MessagePackUnpacker::__construct(boolean $opt = null); // $opt - php.ini msgpack.php_only MessagePackUnpacker::__destruct(); MessagePackUnpacker::setOption(integer $option, boolean $value); // MSGPACK_CLASS_OPT_PHPONLY MessagePackUnpacker::feed(string $str); // . true false. MessagePackUnpacker::execute(string $str = null, integer &$offset = null); // . true false. MessagePackUnpacker::data(mixed $object = null); // , execute false. , $object - reset. , $object MessagePack::unpack reset. MessagePackUnpacker::reset(); // ;
Source: https://habr.com/ru/post/251177/
All Articles