This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
api:serialization:zh [2022/08/11 10:45] fight_xing created |
api:serialization:zh [2023/11/26 23:20] (current) hfsr [Serialization(串连) API] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | Serialization API | + | Serialization(序列化) API |
============= | ============= | ||
- | + | 此模块提供了简单的数值序列化功能。 | |
- | **本篇文章的部分/全部内容还没有进行翻译。** | + | |
- | + | ||
- | This module provides simple value serialization. | + | |
- `serialization.serialize(value: any except functions[, pretty:boolean/number]): string` | - `serialization.serialize(value: any except functions[, pretty:boolean/number]): string` | ||
- | Generates a string from an object that can be parsed again using `serialization.unserialize`. The generated output is Lua code. Supports basic types (nil, boolean, number, string) and tables without cycles (will error out when cycles are detected, unless in `pretty` print mode). Properly handles NaN values and infinity. | + | 通过能重新被`serialization.unserialize`解析的对象创建一个字符串。生成的输出为Lua代码。此函数支持基本类型(nil, boolean, number, string)与不带回环的表(若检测到回环会报错,除非为`pretty`输出模式)。 |
- | The `pretty` mode can be used to generate output for display to the user, this output will in most circumstances not be readable with `serialization.unserialize`. | + | `pretty`(美观)模式用于生成显示给用户的输出,这种输出大多数情况下不能被`serialization.unserialize`读取。 |
- | + | `pretty`的数值决定了将输出的条目数,若`pretty`被设定为`true`则默认会输出10个条目。 | |
- | The value of pretty defines the number of entries that will be printed. | + | 此函数在通过网卡发送数据时可能会有所帮助。 |
- | If pretty is set to true it will by default print 10 entries. | + | \\ |
- | + | ||
- | This function can be useful for sending messages via a network card. | + | |
- `serialization.unserialize(value: string): any` | - `serialization.unserialize(value: string): any` | ||
- | Restores an object previously saved with `serialization.serialize`. | + | 还原先前由`serialization.serialize`创建的对象。 |
- | + | ||
目录 | 目录 | ||
- | ----------- | + | ---------- |
{{page>api:contents:zh&noheader&noeditbutton&nouser&nofooter}} | {{page>api:contents:zh&noheader&noeditbutton&nouser&nofooter}} |