On 2014-08-05 14:40, Daniel Murphy wrote:

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();
}

I'm not saying that is a bad idea or that I don't want to be able to do this. I just prefer this to be handled by a generic serialization module. Which can of course handle the simple cases, like above, as well.

--
/Jacob Carlborg

Reply via email to