copy a JSONValue

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 26 00:20:00 PDT 2016



Dne 26.8.2016 v 08:56 Alex via Digitalmars-d-learn napsal(a):
> 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);
> } 

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.toString.parseJSON;
     j2["code"] = 43;
     writeln("code of j2: ", j2["code"].integer);
     writeln("code of j: ", j["code"].integer);
}


More information about the Digitalmars-d-learn mailing list