1 [comment {-*- tcl -*- doctools manpage}]
2 [manpage_begin json::write n 1.0.1]
3 [copyright {2009-2011 Andreas Kupries <andreas_kupries@sourceforge.net>}]
5 [titledesc {JSON generation}]
6 [category {CGI programming}]
8 [require json::write [opt 1.0.1]]
9 [keywords json javascript {data exchange} {exchange format}]
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].
20 [list_begin definitions]
22 [call [cmd ::json::write] [method indented]]
24 This method returns the current state of the indentation setting.
27 [call [cmd ::json::write] [method indented] [arg flag]]
29 This and the method [method aligned] configure the layout of the JSON
30 generated by the package.
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.
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.
44 [call [cmd ::json::write] [method aligned]]
46 This method returns the current state of the alignment setting.
49 [call [cmd ::json::write] [method aligned] [arg flag]]
52 This and the method [method indented] configure the layout of the JSON
53 generated by the package.
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.
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.
68 [call [cmd ::json::write] [method string] [arg s]]
70 This method takes the string [arg s] and returns it properly quoted
71 for JSON as its result.
74 [call [cmd ::json::write] [method array] [arg arg]...]
76 This method takes a series of JSON formatted arguments and returns
77 them as a properly formatted JSON array as its result.
80 [call [cmd ::json::write] [method object] [arg key] [arg value]...]
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.
91 [include ../doctools2base/include/feedback.inc]