Attachment "ddd" to
ticket [70d8274f90]
added by
anonymous
2015-09-02 01:45:59.
diff -r 6c3a401994f9 modules/json/json.man
--- a/modules/json/json.man Mon Aug 24 11:05:53 2015 +0000
+++ b/modules/json/json.man Tue Sep 01 18:41:45 2015 -0700
@@ -21,17 +21,19 @@
There is some ambiguity in parsing JSON because JSON has type information that
is not maintained by the Tcl conversion. The [package json] package returns
-data as a Tcl [cmd dict]. Either the [package dict] package or Tcl 8.5 is
+data as a Tcl [cmd dict] or [cmd list]. Either the [package dict] package or Tcl 8.5 is
required for use.
+In general, it is not possible to know if the original JSON is an array or an object.
+
[section COMMANDS]
[list_begin definitions]
[call [cmd ::json::json2dict] [arg txt]]
-Parse JSON formatted text [arg txt] into a Tcl dict and return
-the value.
+Parse JSON formatted text [arg txt] and return the value. A JSON object is returned
+as a Tcl dict and a JSON array is returned as a Tcl list.
[para] If [arg txt] contains more than one JSON entity only the
first one is returned.
@@ -40,7 +42,7 @@
[call [cmd ::json::many-json2dict] [arg txt] [opt [arg max]]]
Parse JSON formatted text [arg txt] containing multiple JSON entities
-into a list of dictionaries and return that list.
+into a list of dictionaries and/or lists and return that list.
[para] If [arg max] is specified exactly that many entities are extracted
from [arg txt]. By default the command will attempt to extract all, without
@@ -53,8 +55,7 @@
[section EXAMPLES]
[para]
-An example of a JSON array converted to Tcl. A JSON array is returned as a
-single item with multiple elements.
+An example of a JSON array converted to a Tcl list.
[para]
[example {[
@@ -85,7 +86,7 @@
[para]
An example of a JSON object converted to Tcl. A JSON object is returned as a
-multi-element list (a dict).
+multi-element list which is a valid Tcl dict.
[para]
[example {{