Skip Menu |
 

This queue is for tickets about the JSON-RPC CPAN distribution.

Report information
The Basics
Id: 112467
Status: rejected
Priority: 0/
Queue: JSON-RPC

People
Owner: Nobody in particular
Requestors: denisix [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: double quotes on numeric value in JSON format
Date: Sat, 27 Feb 2016 02:23:20 +0200
To: bug-JSON-RPC [...] rt.cpan.org
From: Den <denisix [...] gmail.com>
Download (untitled) / with headers
text/plain 578b
Hi, I have found that JSON::RPC::Client doesnt work with bitcoin node, after 4 hours of debugging I've found that the issue on JSON format: $content = [{"params":["acc1","acc2","0.0001"],"version":1.1,"method":"move"}] but the correct one should be: $content = [{"params":["acc1","acc2",0.0001],"version":1.1,"method":"move"}] to remove double quotes i've prepared patch for file "Client.pm": Client.pm.patch: 146a147,149 Show quoted text
> # remove double quotes from numeric values > $content =~ s/\"([\d\.\+\-e]+)\"/$1+0/ge; >
Please fix this. Thank you. -- Regards, Den
Download (untitled) / with headers
text/plain 988b
On 2016-02-26 19:23:37, denisix@gmail.com wrote: Show quoted text
> Hi, > > I have found that JSON::RPC::Client doesnt work with bitcoin node, after > 4 hours of debugging I've found that the issue on JSON format: > > $content = > [{"params":["acc1","acc2","0.0001"],"version":1.1,"method":"move"}] > > but the correct one should be: > $content = > [{"params":["acc1","acc2",0.0001],"version":1.1,"method":"move"}] > > to remove double quotes i've prepared patch for file "Client.pm": > > Client.pm.patch: > 146a147,149
> > # remove double quotes from numeric values > > $content =~ s/\"([\d\.\+\-e]+)\"/$1+0/ge; > >
>
JSON::RPC::Client does not seem to exist anymore in current distribution DMAKI/JSON-RPC-1.06.tar.gz Also, doing stringy changes in the already serialized result might not be that robust. It's better to make sure that numeric values are really numeric _before_ the serialization (e.g. by doing something like this: $data->{numeric}+=0; encode_json $data; )
Subject: Re: [rt.cpan.org #112467] double quotes on numeric value in JSON format
Date: Mon, 29 Feb 2016 08:58:21 +0000
To: bug-JSON-RPC [...] rt.cpan.org
From: Den <denisix [...] gmail.com>
Download (untitled) / with headers
text/plain 1.3k
Hi, Even if I provide a really numeric value, e.g. 0+$var encode_json double quotes the float value, and thats the issue. -- С уважением Денис On February 28, 2016 7:34:30 PM GMT+02:00, Slaven_Rezic via RT <bug-JSON-RPC@rt.cpan.org> wrote: Show quoted text
><URL: https://rt.cpan.org/Ticket/Display.html?id=112467 > > >On 2016-02-26 19:23:37, denisix@gmail.com wrote:
>> Hi, >> >> I have found that JSON::RPC::Client doesnt work with bitcoin node,
>after
>> 4 hours of debugging I've found that the issue on JSON format: >> >> $content = >> [{"params":["acc1","acc2","0.0001"],"version":1.1,"method":"move"}] >> >> but the correct one should be: >> $content = >> [{"params":["acc1","acc2",0.0001],"version":1.1,"method":"move"}] >> >> to remove double quotes i've prepared patch for file "Client.pm": >> >> Client.pm.patch: >> 146a147,149
>> > # remove double quotes from numeric values >> > $content =~ s/\"([\d\.\+\-e]+)\"/$1+0/ge; >> >
>>
> >JSON::RPC::Client does not seem to exist anymore in current >distribution DMAKI/JSON-RPC-1.06.tar.gz > >Also, doing stringy changes in the already serialized result might not >be that robust. It's better to make sure that numeric values are really >numeric _before_ the serialization (e.g. by doing something like this: > > $data->{numeric}+=0; > encode_json $data; > >)
Download (untitled) / with headers
text/plain 228b
JSON::RPC::Client is no longer bundled in this distribution, and therefore this ticket is no longer applicable. As to your immediate problems, you should probably consider using JSON::Types https://metacpan.org/pod/JSON::Types
Download (untitled) / with headers
text/plain 507b
On 2016-02-29 03:58:29, denisix@gmail.com wrote: Show quoted text
> Hi, > > Even if I provide a really numeric value, e.g. > > 0+$var > > encode_json double quotes the float value, and thats the issue.
Which json module? Which version? I cannot reproduce this: perl -MCpanel::JSON::XS -E '$num = "3.14159"; $num+=0; say encode_json [$num]' [3.14159] perl -MJSON::XS -E '$num = "3.14159"; $num+=0; say encode_json [$num]' [3.14159] perl -MJSON -E '$num = "3.14159"; $num+=0; say encode_json [$num]' [3.14159]


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.