std.json cannot read an array floats back from file
Yuri via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jul 2 14:07:40 PDT 2017
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;
jj.object["floats"].array[1].floating.writeln;
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 floating type
while the below works fine:
import std.json;
float[] floats = [1,2,3];
JSONValue j = "{}".parseJSON;
j.object["floats"] = floats;
j.object["floats"].array[1].floating.writeln;
any pointers to what could be going wrong?
More information about the Digitalmars-d-learn
mailing list