Commit | Line | Data |
458402ad |
1 | [comment {-*- tcl -*- doctools manpage}] |
2 | [manpage_begin json::write n 1.0.1] |
3 | [copyright {2009-2011 Andreas Kupries <andreas_kupries@sourceforge.net>}] |
4 | [moddesc {JSON}] |
5 | [titledesc {JSON generation}] |
6 | [category {CGI programming}] |
7 | [require Tcl 8.5] |
8 | [require json::write [opt 1.0.1]] |
9 | [keywords json javascript {data exchange} {exchange format}] |
10 | [description] |
11 | [para] |
12 | |
13 | The [package json::write] package provides a simple Tcl-only library |
14 | for generation of text in the JSON [uri http://www.json.org/] data |
15 | exchange format as specified in |
16 | RFC 4627 [uri http://www.ietf.org/rfc/rfc4627.txt]. |
17 | |
18 | [section COMMANDS] |
19 | |
20 | [list_begin definitions] |
21 | |
22 | [call [cmd ::json::write] [method indented]] |
23 | |
24 | This method returns the current state of the indentation setting. |
25 | |
26 | |
27 | [call [cmd ::json::write] [method indented] [arg flag]] |
28 | |
29 | This and the method [method aligned] configure the layout of the JSON |
30 | generated by the package. |
31 | |
32 | [para] |
33 | |
34 | If this [arg flag] is set (default) the package will break the |
35 | generated JSON code across lines and indent it according to its inner |
36 | structure, with each key of an object on a separate line. |
37 | |
38 | [para] |
39 | |
40 | If this flag is not set, the whole JSON object will be written on a |
41 | single line, with minimum spacing between all elements. |
42 | |
43 | |
44 | [call [cmd ::json::write] [method aligned]] |
45 | |
46 | This method returns the current state of the alignment setting. |
47 | |
48 | |
49 | [call [cmd ::json::write] [method aligned] [arg flag]] |
50 | |
51 | |
52 | This and the method [method indented] configure the layout of the JSON |
53 | generated by the package. |
54 | |
55 | [para] |
56 | |
57 | If this [arg flag] is set (default) the package ensures that the |
58 | values for the keys in an object are vertically aligned with each |
59 | other, for a nice table effect. To make this work this also implies |
60 | that [var indented] is set as well. |
61 | |
62 | [para] |
63 | |
64 | If this flag is not set, the output is formatted as per the value of |
65 | [var indented], without trying to align the values for object keys. |
66 | |
67 | |
68 | [call [cmd ::json::write] [method string] [arg s]] |
69 | |
70 | This method takes the string [arg s] and returns it properly quoted |
71 | for JSON as its result. |
72 | |
73 | |
74 | [call [cmd ::json::write] [method array] [arg arg]...] |
75 | |
76 | This method takes a series of JSON formatted arguments and returns |
77 | them as a properly formatted JSON array as its result. |
78 | |
79 | |
80 | [call [cmd ::json::write] [method object] [arg key] [arg value]...] |
81 | |
82 | This method takes a series of key/value arguments, the values already |
83 | formatted for JSON, and returns them as a properly formatted JSON |
84 | object as its result, with the keys formatted as JSON strings. |
85 | |
86 | |
87 | [list_end] |
88 | [para] |
89 | |
90 | [vset CATEGORY json] |
91 | [include ../doctools2base/include/feedback.inc] |
92 | [manpage_end] |