[Pkg-tcltk-devel] Bug#764972: tcllib: json package produces incorrect json objects (unquoted values, nesting)

John Kennerson nobody at isis.cpunk.us
Sun Oct 12 13:01:04 UTC 2014


Package: tcllib
Version: 1.14-dfsg-3
Severity: normal

Dear Maintainer,

The json package does not product proper json objects from tcl dict
objects.  Specifically:

1) The last element in the record has a trailing comma
2) The keys are quoted, but the values are not
3) Nested dict objects are not correctly nested in a json structure

Problem 1 was solved in a later teacup Windows version, but apparently
not in debian.

This script demonstrates problem 1 and 2:

=====8<----------------------------------------
#!/usr/bin/tclsh8.5

package require json

set some_address [dict create street       {sesame street}\
             	   	      house_number 123\
	               	      city         bronx]

puts "[::json::dict2json $some_address]"
=====8<----------------------------------------

The erroneous output is:

  {"street": sesame street,
  "house_number": 123,
  "city": bronx,
  }

Note that the keys are quoted, but the values are not.  The values
should be quoted.  And worse, notice that the last field is followed
by a comma.

Problem 3 - broken nesting:
=====8<----------------------------------------
#!/usr/bin/tclsh8.5

package require json

set some_address [dict create street       {sesame street}\
             	   	      house_number 123\
	               	      city         bronx]

# Nesting broken too:
set person [dict create name {big bird} address $some_address]

puts "[::json::dict2json $person]"
=====8<----------------------------------------

Output is:

{"name": big bird,
"address": street {sesame street} house_number 123 city bronx,
}

Note that the address field should contain another complete json
structure within it.  The 2nd and 3rd defect apparently exists in all
versions.

-- System Information:
Debian Release: 7.6
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages tcllib depends on:
ii  tcl             8.5.0-2.1
ii  tcl8.5 [tclsh]  8.5.11-2

tcllib recommends no packages.

tcllib suggests no packages.

-- no debconf information



More information about the Pkg-tcltk-devel mailing list