Module rsjson¶
Require: require("rsjson")
Index¶
Data
Low-level serde API |
Function
Deserialize a JSON string into a Lua object |
|
Serialize a Lua object into a JSON string |
|
Deserialize a JSON object from a file |
|
Deserialize a JSON object from a string |
|
Serialize a Lua object to a file |
|
Serialize a Lua object to a string |
Class
Alias
Represents the JSON null value. This can be used in the place of nil to represent empty values. |
Api reference¶
-
rsjson.serde:
table¶ Low-level serde API
-
alias rsjson.null =
lightuserdata¶ Represents the JSON
nullvalue. This can be used in the place ofnilto represent empty values.
-
class rsjson.EncodeConfig:
userdata¶ -
indent:
number¶ The number of
prefixto indent lines
-
prefix:
string¶ The string to use for indentation
-
sort_keys:
boolean¶ Sort JSON keys
-
empty_table_as_array:
boolean¶ Convert empty tables to empty arrays
-
detect_mixed_tables:
boolean¶ Detect mixed sequence and key tables
-
error_unsupported:
boolean¶ Error on unsupported types (functions, userdata, etc)
-
error_cycles:
boolean¶ Error on cycles
-
new: fun():
rsjson.EncodeConfig¶
-
indent:
-
class rsjson.DecodeConfig:
userdata¶ -
null:
boolean¶ Convert
niltorsjson.null
-
cast_u64_to_f64:
boolean¶ Convert u64 numbers to f64 if they overflow i64
-
set_array_mt:
boolean¶ Set the metatable of JSON array tables to
mlua::Lua::array_metatable
-
new: fun():
rsjson.DecodeConfig¶
-
null:
-
rsjson.encode(obj:
any, config?:rsjson.EncodeConfig):string¶ Serialize a Lua object into a JSON string
- Parameters:
obj (
any) – Any Lua object- Returns:
_1 (
string) – The serialized Lua object
-
rsjson.decode(str:
string, config?:rsjson.DecodeConfig):any¶ Deserialize a JSON string into a Lua object
- Parameters:
str (
string) – The JSON string- Returns:
_1 (
any) – The deserialized JSON object
-
rsjson.to_file(obj:
any, path:string, indent?:number):string¶ Serialize a Lua object to a file
- Parameters:
obj (
any) – Any Lua objectpath (
string) – The filepath to write toindent? (
number) – The indent level of lines
- Returns:
_1 (
string) – The serialized Lua object
-
rsjson.to_str(obj:
any, indent?:number):string¶ Serialize a Lua object to a string
- Parameters:
obj (
any) – Any Lua objectindent? (
number) – The indent level of lines
- Returns:
_1 (
string) – The serialized Lua object
-
rsjson.from_file(path:
string):any¶ Deserialize a JSON object from a file
- Parameters:
path (
string) – The filepath to load- Returns:
_1 (
any) – The deserialized JSON object
-
rsjson.from_str(str:
string):any¶ Deserialize a JSON object from a string
- Parameters:
str (
string) – The string to load- Returns:
_1 (
any) – The deserialized JSON object