luaserialization, v1.3.0
Posted on

The library that implements various auxiliary functions for serialization.
Support for saving values to JSON files and loading them back.
Disclaimer: this library was written directly on an Android smartphone with the QLua IDE.
Change Log
- serialization to JSON:
json.save_to_json()function — this function serializes the passed value to the JSON with thejson.to_json()function and saves the result to the file at the specified path via the file writer:- the default implementation of the file writer uses the standard
iopackage;
- the default implementation of the file writer uses the standard
json.load_from_json()function — this function loads the JSON via the file reader and transforms it to a data with thejson.from_json()function:- optionally, it can validate the data against a JSON Schema;
- optionally, it can recreate tables with the
__nameproperty with the passed constructors; - the default implementation of the file reader uses the standard
iopackage;
- the
jsonmodule now supports Lua 5.1;
- project maintenance:
- added Lua 5.5 to the test matrix and restored standard LuaJIT testing;
- updated the minimum supported version of the
luatypechecksdependency to 1.3.4.
Features
data.to_data()function — this function recursively calls the__data()metamethod if it exists:- supports for enhancing tables with the
__namemetaproperty;
- supports for enhancing tables with the
Nameablemixin — this mixin adds the__namemetaproperty to a class created by library middleclass; this metaproperty equals to thenameproperty of the mix target class;- serialization to string:
string.to_string()function — this function calls thedata.to_data()function and then applies library inspect.lua;Stringifiablemixin — this mixin adds the__tostring()metamethod that calls thestring.to_string()function;
- serialization to JSON:
json.to_json()function — this function calls thedata.to_data()function and then transforms the data into the JSON;json.save_to_json()function — this function serializes the passed value to the JSON with thejson.to_json()function and saves the result to the file at the specified path via the file writer:- the default implementation of the file writer uses the standard
iopackage;
- the default implementation of the file writer uses the standard
json.from_json()function — this function transforms the text in the JSON to a data:- optionally, it can validate the data against a JSON Schema;
- optionally, it can recreate tables with the
__nameproperty with the passed constructors;
json.load_from_json()function — this function loads the JSON via the file reader and transforms it to a data with thejson.from_json()function:- optionally, it can validate the data against a JSON Schema;
- optionally, it can recreate tables with the
__nameproperty with the passed constructors; - the default implementation of the file reader uses the standard
iopackage.
Repository
Link: https://github.com/thewizardplusplus/luaserialization/tree/v1.3.0.
Content: code.
License: MIT.