add bjson library & update /doc/en/scripting/filesystem.md
This commit is contained in:
@@ -75,6 +75,55 @@ file.mkdirs(path: str) -> bool
|
||||
|
||||
Create directories chain. Returns true if new directory created.
|
||||
|
||||
## *json* library
|
||||
|
||||
The library contains functions for serializing and deserializing tables:
|
||||
|
||||
```python
|
||||
json.tostring(object: table, human_readable: bool=false) -> str
|
||||
```
|
||||
|
||||
Serializes an object into a JSON string. If the second parameter is **true**, multi-line human-readable formatting will be used, rather than the compact format used by default.
|
||||
|
||||
```python
|
||||
json.parse(code: str) -> table
|
||||
```
|
||||
|
||||
Parses a JSON string into a table.
|
||||
|
||||
## *toml* library
|
||||
|
||||
The library contains functions for serializing and deserializing tables:
|
||||
|
||||
```python
|
||||
toml.tostring(object: table) -> str
|
||||
```
|
||||
|
||||
Serializes an object into a TOML string.
|
||||
|
||||
```python
|
||||
toml.parse(code: str) -> table
|
||||
```
|
||||
|
||||
Parses a TOML string into a table.
|
||||
|
||||
## *bjson* library
|
||||
|
||||
The library contains functions for working with the binary data exchange format [vcbjson](../../specs/binary_json_spec.md).
|
||||
|
||||
```lua
|
||||
-- Encodes a table into a byte array
|
||||
bjson.tobytes(
|
||||
-- encoded table
|
||||
value: table,
|
||||
-- compression
|
||||
[optional] compression: bool=true
|
||||
) --> Bytearray
|
||||
|
||||
-- Decodes a byte array into a table
|
||||
bjson.frombytes(bytes: table | Bytearray) --> table
|
||||
```
|
||||
|
||||
## Storing data in a world
|
||||
|
||||
When saving pack data in the world, you should use the function:
|
||||
|
||||
@@ -125,6 +125,23 @@ toml.parse(code: str) -> table
|
||||
|
||||
Парсит TOML строку в таблицу.
|
||||
|
||||
## Библиотека bjson
|
||||
|
||||
Библиотека содержит функции для работы с двоичным форматом обмена данными [vcbjson](../../specs/binary_json_spec.md).
|
||||
|
||||
```lua
|
||||
-- Кодирует таблицу в массив байт
|
||||
bjson.tobytes(
|
||||
-- кодируемая таблица
|
||||
value: table,
|
||||
-- сжатие
|
||||
[опционально] compression: bool=true
|
||||
) --> Bytearray
|
||||
|
||||
-- Декодирует массив байт в таблицу
|
||||
bjson.frombytes(bytes: table | Bytearray) --> table
|
||||
```
|
||||
|
||||
## Сохранение данных в мире
|
||||
|
||||
При сохранении данных пака в мире следует использовать функцию
|
||||
|
||||
Reference in New Issue
Block a user