1json(n)                           JSON parser                          json(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       json - JSON parser
9

SYNOPSIS

11       package require Tcl  8.4
12
13       package require json  ?1.0?
14
15       ::json::json2dict txt
16
17_________________________________________________________________
18

DESCRIPTION

20       The  json  package  provides  a simple Tcl-only library for parsing the
21       JSON http://www.json.org/ data exchange format as specified in RFC 4627
22       http://www.ietf.org/rfc/rfc4627.txt.   There is some ambiguity in pars‐
23       ing JSON because JSON has type information that is  not  maintained  by
24       the  Tcl  conversion.   The  json  package  returns data as a Tcl dict.
25       Either the dict package or Tcl 8.5 is required for use.
26

COMMANDS

28       ::json::json2dict txt
29              Parse JSON formatted text txt into a Tcl  dict  and  return  the
30              value.
31

EXAMPLES

33       An  example of a JSON array converted to Tcl.  A JSON array is returned
34       as a single item with multiple elements.
35
36       [
37           {
38              "precision": "zip",
39              "Latitude":  37.7668,
40              "Longitude": -122.3959,
41              "Address":   "",
42              "City":      "SAN FRANCISCO",
43              "State":     "CA",
44              "Zip":       "94107",
45              "Country":   "US"
46           },
47           {
48              "precision": "zip",
49              "Latitude":  37.371991,
50              "Longitude": -122.026020,
51              "Address":   "",
52              "City":      "SUNNYVALE",
53              "State":     "CA",
54              "Zip":       "94085",
55              "Country":   "US"
56           }
57       ]
58       =>
59       {Country US Latitude 37.7668 precision zip State CA City {SAN FRANCISCO} Address {} Zip 94107 Longitude -122.3959} {Country US Latitude 37.371991 precision zip State CA City SUNNYVALE Address {} Zip 94085 Longitude -122.026020}
60
61
62       An example of a JSON  object  converted  to  Tcl.   A  JSON  object  is
63       returned as a multi-element list (a dict).
64
65       {
66           "Image": {
67               "Width":  800,
68               "Height": 600,
69               "Title":  "View from 15th Floor",
70               "Thumbnail": {
71                   "Url":    "http://www.example.com/image/481989943",
72                   "Height": 125,
73                   "Width":  "100"
74               },
75               "IDs": [116, 943, 234, 38793]
76           }
77       }
78       =>
79       Image {IDs {116 943 234 38793} Thumbnail {Width 100 Height 125 Url http://www.example.com/image/481989943} Width 800 Height 600 Title {View from 15th Floor}}
80
81

KEYWORDS

83       data exchange, exchange format, javascript, json
84
86       Copyright (c) 2006 ActiveState Software Inc.
87
88
89
90
91json                                  1.0                              json(n)
Impressum