std.json cannot read an array floats back from file

2017-07-02 Thread Yuri via Digitalmars-d-learn
Hi there, consider the following simple use case: import std.json; float[] floats = [1,2,3]; JSONValue j = "{}".parseJSON; j.object["floats"] = floats; std.file.write("test.json", j.toString); JSONValue jj = readText("test.json").parseJSON;

Re: std.json cannot read an array floats back from file

2017-07-03 Thread Yuri via Digitalmars-d-learn
On Monday, 3 July 2017 at 13:34:50 UTC, Adam D. Ruppe wrote: On Monday, 3 July 2017 at 13:26:52 UTC, Yuri wrote: Yes, when accessing .integer instead of .floating then it works, unfortunately that is not suitable for the task at hand, it has to be a float. Just write a helper function that

Re: std.json cannot read an array floats back from file

2017-07-03 Thread Yuri via Digitalmars-d-learn
On Monday, 3 July 2017 at 14:04:47 UTC, ketmar wrote: Yuri wrote: On Sunday, 2 July 2017 at 21:15:41 UTC, ketmar wrote: [...] I share your sentiment in relation to std.json, ketmar. On a side note, what would be a better way to serialize/deserialize objects in D if std.json does not cut

Re: std.json cannot read an array floats back from file

2017-07-03 Thread Yuri via Digitalmars-d-learn
On Sunday, 2 July 2017 at 21:15:41 UTC, ketmar wrote: so, write your own wrapper that will convert INTEGER/UINTEGER/FLOAT to `double`. i think this is the best solution (if there can be "best solution" with std.json at all). I share your sentiment in relation to std.json, ketmar. On a side

Re: std.json cannot read an array floats back from file

2017-07-03 Thread Yuri via Digitalmars-d-learn
On Sunday, 2 July 2017 at 21:12:48 UTC, Adam D. Ruppe wrote: On Sunday, 2 July 2017 at 21:07:40 UTC, Yuri wrote: It is expected to print '2' in the console, however an exception is thrown: std.json.JSONException@/build/ldc-I3nwWj/ldc-0.17.1/runtime/phobos/std/json.d(235): JSONValue is not a