Hi everybody,
I'm little at loss: as documented, a JSONValue is only shallow copied:

void main()
{
    import std.json;
    import std.stdio;

string s = "{ \"language\": \"D\", \"rating\": 3.14, \"code\": 42 }";
    JSONValue j = parseJSON(s);
    writeln("code: ", j["code"].integer);

    auto j2 = j;
    j2["code"] = 43;
    writeln("code of j2: ", j2["code"].integer);
    writeln("code of j: ", j["code"].integer);
}

So the effect that the code of "j" is altered was expected.

The question is: how to make a deep copy of a JSONValue? Is there a simple way without copying the source string around? Or, would this be the simplest way?

Thanks in advance
Alex

Reply via email to