diff options
author | ShadowNinja <shadowninja@minetest.net> | 2013-12-18 16:46:53 -0500 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2013-12-18 16:46:53 -0500 |
commit | 1ed90c90c304c6cc9cfddb722e4d15a1221d0177 (patch) | |
tree | 915dec8c285fa72866c5f250e84bec9af339fc11 /doc | |
parent | 49cec3f78240ed6310a9b5dd05ce09a79ed5a12e (diff) | |
download | minetest-1ed90c90c304c6cc9cfddb722e4d15a1221d0177.tar.gz minetest-1ed90c90c304c6cc9cfddb722e4d15a1221d0177.tar.bz2 minetest-1ed90c90c304c6cc9cfddb722e4d15a1221d0177.zip |
Add 'minetest.write_json'
Diffstat (limited to 'doc')
-rw-r--r-- | doc/lua_api.txt | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt index abfb8f94b..135e2cfcd 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1530,7 +1530,16 @@ minetest.parse_json(string[, nullvalue]) -> something ^ nullvalue: returned in place of the JSON null; defaults to nil ^ On success returns a table, a string, a number, a boolean or nullvalue ^ On failure outputs an error message and returns nil -^ Example: parse_json("[10, {\"a\":false}]") -> {[1] = 10, [2] = {a = false}} +^ Example: parse_json("[10, {\"a\":false}]") -> {10, {a = false}} +minetest.write_json(data[, styled]) -> string +^ Convert a Lua table into a JSON string +^ styled: Outputs in a human-readable format if this is set, defaults to false +^ Un-serializable things like functions and userdata are saved as null. +^ Warning: JSON is more strict than the Lua table format. + 1. You can only use strings and positive integers of at least one as keys. + 2. You can not mix string and integer keys. + This is due to the fact that Javascript has two distinct array and object values. +^ Example: write_json({10, {a = false}}) -> "[10, {\"a\": false}]" minetest.serialize(table) -> string ^ Convert a table containing tables, strings, numbers, booleans and nils into string form readable by minetest.deserialize |