import json package
[scpubgit/TenDotTcl.git] / json / json_write.man
CommitLineData
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
13The [package json::write] package provides a simple Tcl-only library
14for generation of text in the JSON [uri http://www.json.org/] data
15exchange format as specified in
16RFC 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
24This method returns the current state of the indentation setting.
25
26
27[call [cmd ::json::write] [method indented] [arg flag]]
28
29This and the method [method aligned] configure the layout of the JSON
30generated by the package.
31
32[para]
33
34If this [arg flag] is set (default) the package will break the
35generated JSON code across lines and indent it according to its inner
36structure, with each key of an object on a separate line.
37
38[para]
39
40If this flag is not set, the whole JSON object will be written on a
41single line, with minimum spacing between all elements.
42
43
44[call [cmd ::json::write] [method aligned]]
45
46This method returns the current state of the alignment setting.
47
48
49[call [cmd ::json::write] [method aligned] [arg flag]]
50
51
52This and the method [method indented] configure the layout of the JSON
53generated by the package.
54
55[para]
56
57If this [arg flag] is set (default) the package ensures that the
58values for the keys in an object are vertically aligned with each
59other, for a nice table effect. To make this work this also implies
60that [var indented] is set as well.
61
62[para]
63
64If 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
70This method takes the string [arg s] and returns it properly quoted
71for JSON as its result.
72
73
74[call [cmd ::json::write] [method array] [arg arg]...]
75
76This method takes a series of JSON formatted arguments and returns
77them as a properly formatted JSON array as its result.
78
79
80[call [cmd ::json::write] [method object] [arg key] [arg value]...]
81
82This method takes a series of key/value arguments, the values already
83formatted for JSON, and returns them as a properly formatted JSON
84object 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]