| 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: | Closed | Last Modified: | 2026-11-21 08:42:17 | |
| Resolution: | Fixed | Closed By: | serhiy.storchaka | |
| Closed on: | 2026-11-21 08:42:16 | |||
| 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: |
serhiy.storchaka added on 2026-11-21 08:42:17:
Since the huddle 0.2 rewrite ([02ec11eeba], Tcllib 1.18) values given to huddle create are strings and are always quoted by jsondump, so 000000 becomes "000000" and json2dict reads it back. Verified: huddle 0.1.5 produces the invalid JSON, current trunk does not (Tcl 8.6 and 9.1). Numbers now have to be created explicitly with huddle number. 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?
| |||
Home
Blog
Docs
Downloads
Tickets
Timeline
Branches
Tags
Wiki