Tcl Library Source Code

View Ticket
Login
Ticket UUID: 2df194042b2acd13c60b0dd92cdf55c1a0ef3bde
Title: json2dict does not always produce a dictionary
Type: Bug Version: 1.3.3
Submitter: nmadden Created on: 2015-01-16 10:20:31
Subsystem: json Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2015-01-16 10:20:31
Resolution: None Closed By: nobody
    Closed on:
Description:
The json::json2dict procedure is named and documented as if it produces a dictionary output in all cases. This is incorrect, as per these examples where the output is a string/number/list:

% package require json
1.3.3
% json::json2dict {true}
true
% json::json2dict {1234.45}
1234.45
% json::json2dict {"Hello, World!"}
Hello, World!
% json::json2dict {[1,2,3,4]}
1 2 3 4

The documentation (and ideally the name) should be updated to make clear that it only returns a dictionary if the input is a JSON object, and that the caller *must know* the type of JSON data being parsed in order to know how to interpret the result correctly. I have seen several questions on TkChat and c.l.t that suggest that this is confusing people.