"Jacob Carlborg" wrote in message
news:kvuaxyxjwmpqrorlo...@forum.dlang.org...
> This is exactly what I need in most projects. Basic types, arrays, AAs,
> and structs are usually enough.
I was more thinking only types that cannot be broken down in to smaller
pieces, i.e. integer, floating point, bool and string. The serializer
would break down the other types in to smaller pieces.
I guess I meant types that have an obvious mapping to json types.
int/long -> json integer
bool -> json bool
string -> json string
float/real -> json float (close enough)
T[] -> json array
T[string] -> json object
struct -> json object
This is usually enough for config and data files. Being able to do this is
just awesome:
struct AppConfig
{
string somePath;
bool someOption;
string[] someList;
string[string] someMap;
}
void main()
{
auto config = "config.json".readText().parseJSON().fromJson!AppConfig();
}
Being able to serialize whole graphs into json is something I need much less
often.