Re: copy a JSONValue

2016-08-26 Thread Alex via Digitalmars-d-learn
On Friday, 26 August 2016 at 08:21:14 UTC, Alex wrote: On Friday, 26 August 2016 at 07:20:00 UTC, Daniel Kozak wrote: auto j2 = j.toString.parseJSON; ha! cool! thanks! :) found a bug... https://issues.dlang.org/show_bug.cgi?id=16432 not very serious... but not found yet? ;)

Re: copy a JSONValue

2016-08-26 Thread Alex via Digitalmars-d-learn
On Friday, 26 August 2016 at 07:46:13 UTC, Daniel Kozak wrote: Another way is to implement deepCopy by yourself (something like below) import std.json; import std.stdio; JSONValue deepCopy(ref JSONValue val) { JSONValue newVal; switch(val.type) { case JSON_TYPE.STRING:

Re: copy a JSONValue

2016-08-26 Thread Alex via Digitalmars-d-learn
On Friday, 26 August 2016 at 07:20:00 UTC, Daniel Kozak wrote: auto j2 = j.toString.parseJSON; ha! cool! thanks! :)

Re: copy a JSONValue

2016-08-26 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 26 August 2016 at 06:56:06 UTC, Alex wrote: Hi everybody, I'm little at loss: as documented, a JSONValue is only shallow copied: ... 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

Re: copy a JSONValue

2016-08-26 Thread Daniel Kozak via Digitalmars-d-learn
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["c

copy a JSONValue

2016-08-26 Thread Alex via Digitalmars-d-learn
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);