Module jls.lang.serialization
Provides value serialization to string and deserialization from.
Serialization allows to share objects, class instances, between Lua states. Some serialization implementation could bring restriction such as the same Lua state, process or OS.
Functions
| serialize (...) | Returns the serialized string corresponding to the specified values. |
| serializeError (message) | Returns the serialized string corresponding to an error. |
| deserialize ([pos], s, ...) | Returns the values read from the specified serialized string. |
Functions
- serialize (...)
-
Returns the serialized string corresponding to the specified values.
The primitive types, boolean, number, string and nil can be serialized. The objects implementing a serialize method can be serialized. The tables containg serializable values can be serialized.Parameters:
- ... the value to serialize
Returns:
-
string
the serialized string
- serializeError (message)
-
Returns the serialized string corresponding to an error.
The deserialization will raise the specified error message.Parameters:
- message the error message to serialize
Returns:
-
string
the serialized string
- deserialize ([pos], s, ...)
-
Returns the values read from the specified serialized string.
The expected types could be enclosed with brackets
{}to indicate the expected types in a table, optionally the table key types could be passed followed by the equal sign=. The object constructor is not called, the deserialize method is in charge to initialize the object including its inheritance.Parameters:
- pos number the optional position in the string value, default to 1 (optional)
- s string the string value to deserialize
- ...
string
the expected types or class names, defaults to any type,
?and any count
Returns:
-
the deserialized values