[Vala] Fwd: Serialization of objects & Gee.lists



Dear all
Attached you will find native Vala code to serialize object properties
recursively into text.
It provides full support for Gee.List (however, requires that the
Gee.List properties are already initialized with the type of list to
use, e.g. ArrayList etc.).
Resulting text is not exactly JSON as it removes some unnecessary
bytes and encodes object classes which are subclasses of the Gee.List
generic to allow de-serializing them,
i.e., arbitrary container objects can be added to a Gee.List<Object> which
are then automatically instantiated when the object is created.
The code can be used also to parse configurations and can be
configured to work without field names (by using the same order for
serialization as for de-serialization) and to ignore white-space.

Here is example output of one of the included tests:
{dataVal=3,
content=[{testInt=3,testDouble=6,testFloat=2.3,testString="hallo",myEnum=0}{testInt=2,testDouble=4,testFloat=1.2,testString="msg",myEnum=0}{testInt=4,testDouble=2.1,testFloat=3.1,testString="test\\"with
slashes\\"e",myEnum=0}],
intlist=[3,5],
dbllist=[2.5],
emptylist=[]}

While the code is not well documented (yet) and has been written
quickly, I still wanted to contribute it, since people asked on the
list how to accomplish serialization/de-serialization.
There is also code which automatically loads modules and initializes
them with options based on a configuration file for all modules.
If you have further interest, I could clean the code a bit.

Thanks for Vala.

Regards,
Julian


-- 
http://wr.informatik.uni-hamburg.de/people/julian_kunkel

Attachment: serialization-aon.vala
Description: Binary data

Attachment: serialization-helper.vala
Description: Binary data

Attachment: serialization-helper-test.vala
Description: Binary data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]