jayduhon / inferno-os

Automatically exported from code.google.com/p/inferno-os
2 stars 0 forks source link

json(2) JValue.Real.text() return wrong json #230

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Right now text() for JValue.Real implemented as:

    Real =>
        return string r.value;

For values like 0.123 this will produce string ".123", which doesn't
conform to JSON standard.
For example, Perl module JSON::XS failed to read json generated this way.

Fix is simple:

    Real =>
        return sys->sprint("%f", r.value);

Original issue reported on code.google.com by powerman...@gmail.com on 20 Mar 2010 at 5:36

GoogleCodeExporter commented 9 years ago

Original comment by Charles....@gmail.com on 20 Mar 2010 at 10:43

GoogleCodeExporter commented 9 years ago
Oops. Same fix should be applied in writeval() too.

And, probably, to my asstr() in issue 229 (just for consistency).

Original comment by powerman...@gmail.com on 8 Apr 2011 at 2:32

GoogleCodeExporter commented 9 years ago
yes, quite.

Original comment by Charles....@gmail.com on 8 Apr 2011 at 2:39

GoogleCodeExporter commented 9 years ago
committed changeset 509:bb61715a56c2

writeval invokes .text for Int and Real so they have consistent format

Original comment by Charles....@gmail.com on 8 Apr 2011 at 2:40