@@ -39,6 +39,10 @@ Below is a list of all ``msgpack`` functions and members.
39
39
| :ref: `msgpack.NULL | Analog of Lua's "nil" |
40
40
| <msgpack-null>` | |
41
41
+--------------------------------------+---------------------------------+
42
+ | :ref: `msgpack.cfg | Change configuration |
43
+ | <msgpack-cfg>` | |
44
+ +--------------------------------------+---------------------------------+
45
+
42
46
43
47
.. module :: msgpack
44
48
@@ -226,8 +230,38 @@ with the MsgPack format name and encoding on the right.
226
230
| 1.5 | 'float 64' = cb 3f f8 00 00 00 00 00 00 |
227
231
+--------------+-------------------------------------------------+
228
232
229
- Also, some MsgPack configuration settings for encoding can be changed, in the
230
- same way that they can be changed for :ref: `JSON <json-module_cfg >`.
233
+ .. _msgpack-cfg :
234
+
235
+ .. function :: cfg(table)
236
+
237
+ Some MsgPack configuration settings can be changed, in the
238
+ same way that they can be changed for json.
239
+ See :ref: `Module JSON <json-module_cfg >` for a list of some configuration settings.
240
+ (The same configuration settings exist for json, for MsgPack, and for :ref: `YAML <yaml-module >`.)
241
+
242
+ For example, if ``msgpack.cfg.encode_invalid_numbers = true `` (the default),
243
+ then nan and inf are legal values. If that is not desirable, then
244
+ ensure that ``msgpack.encode() `` will not accept them, by saying
245
+ ``msgpack.cfg{encode_invalid_numbers = false} ``, thus:
246
+
247
+ .. code-block :: none
248
+
249
+ tarantool> msgpack = require('msgpack'); msgpack.cfg{encode_invalid_numbers = true}
250
+ ---
251
+ ...
252
+ tarantool> msgpack.decode(msgpack.encode{1, 0 / 0, 1 / 0, false})
253
+ ---
254
+ - [1, -nan, inf, false]
255
+ - 22
256
+ ...
257
+ tarantool> msgpack.cfg{encode_invalid_numbers = false}
258
+ ---
259
+ ...
260
+ tarantool> msgpack.decode(msgpack.encode{1, 0 / 0, 1 / 0, false})
261
+ ---
262
+ - error: ... number must not be NaN or Inf'
263
+ ...
264
+
231
265
232
266
.. _MsgPack : http://msgpack.org/
233
267
.. _Specification : http://github.com/msgpack/msgpack/blob/master/spec.md
0 commit comments