JSONValue x = "data.json".readText.parseJSON;
struct User {
int age;
string name;
this(JSONValue user) {
age = user["age"];
name = user["name"];
}
}
auto user = User(x);
We could use the JSONValue x as it is, but if we want to fill a given structure the best is to define a specific constructor.