std.json cannot read an array floats back from file
Yuri via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 3 06:26:52 PDT 2017
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 floating type
>
>
> I think it just read the json string of "1" as being an integer
> instead of a float, so the reader thought it was integral
> instead of floating.
>
> It should prolly just transparently auto-convert, but it
> doesn't seem to. Try accessing the int instead and see waht
> happens.
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.
More information about the Digitalmars-d-learn
mailing list