Hello everyone! When my https://github.com/dlang/phobos/pull/8662 predictably failed, I moved on to create a common serialization library instead that could later on be included in phobos. So I would like to request a review from you to get it to a decent state. If interested, you can find the code here, and if you want to use it with dub you can use "mud": "~>0.3.0"
.
Code contains two files: package.d to ease making serializators, and json.d is an example serializator from/to json. Please consider this example to see how it works in general:
struct Foo
{
// Works with or without brackets
@serializable int a = 123;
@serializable() double floating = 123;
@serializable("flag") bool check = true;
}
// Will produce `{"a":123,"floating"=123,"flag"=true}`
serializeToJSONString(Foo());
If you're interested in making a custom serializator, here's a rough idea on how it's going to be implemented with this library:
foreach(alias prop; readableSerializables!T)
{
enum name = getSerializableName!prop;
// Work your magic here
}
I tried to make it as universal as I could, but any suggestions are welcome for a discussion.