Tcl Library Source Code

View Ticket
Login
Ticket UUID: 3315620
Title: Invalid JSON with values that begin with 0
Type: Bug Version: None
Submitter: Created on: 2011-06-13 05:46:37
Subsystem: huddle Assigned To:
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2013-11-18 21:28:27
Resolution: None Closed By: nobody
    Closed on:
Description:
I think [huddle jsondump] should quote values with a beginning zero:

::json::json2dict [huddle jsondump [huddle create key 000000]]

--> unexpected token "0" at position 5; expecting ","|"}"

::json::json2dict [huddle jsondump [huddle create key 1000000]]

--> key 1000000

PS
The category huddle is missing!
User Comments: anonymous (claiming to be Ryan Fox) added on 2013-11-18 21:28:27:
The "string" values should be checked with this in ::huddle::jsondump in order to determine if they are valid numbers in JSON:

[regexp {^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$} $data]

added on 2011-08-23 11:34:04:
I don’t know about YAML, I only know that with JSON values like this should be quoted.

kanryu6 added on 2011-08-18 16:03:46:
by the way,

according to http://yaml.org/spec/1.1/
> Example 2.19. Integers
> 
> canonical: 12345
> decimal: +12,345
> sexagesimal: 3:25:45
> octal: 014
> hexadecimal: 0xC

do you think, the integer 000000 is regal?

added on 2011-08-12 11:13:51:
Any chance this bug will be fixed?

kanryu6 added on 2011-06-16 02:50:13:
>% huddle jsondump [huddle create key 000000]

>{"key": 000000}

this is a miss logic about huddle-lib in jsondump sub-command.

the token '000000' should output as '0' or "000000" (string),
but jsondump outputs as raw '000000'.

because in huddle.tcl:455,

> if {[string is double -strict $data]} {return $data}

'string is double' returns 1, and the line returns raw.

but I don't know to treat vague values strictly.

current huddle classify only 'string' / 'list' / 'dict' only.

for example, in jsondump, each token will be considered dynamically.

comments?