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





---------- Forwarded message ----------
From: Julian Kunkel <juliankunkel googlemail com>
Date: 2013/3/13
Subject: [Vala] Fwd: Serialization of objects & Gee.lists
To: vala-list gnome org


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

_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list




--
Trabajar, la mejor arma para tu superación
"de grano en grano, se hace la arena" (R) (en trámite, pero para los cuates: LIBRE)

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]