File: json_write.man

package info (click to toggle)
tcllib 1.14-dfsg-3%2Bdeb7u1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 33,036 kB
  • sloc: tcl: 148,302; ansic: 14,067; sh: 10,320; xml: 1,766; yacc: 753; pascal: 551; makefile: 129; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (92 lines) | stat: -rw-r--r-- 2,589 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin json::write n 1.0.1]
[copyright {2009-2011 Andreas Kupries <andreas_kupries@sourceforge.net>}]
[moddesc   {JSON}]
[titledesc {JSON generation}]
[category  {CGI programming}]
[require Tcl 8.5]
[require json::write [opt 1.0.1]]
[keywords json javascript {data exchange} {exchange format}]
[description]
[para]

The [package json::write] package provides a simple Tcl-only library
for generation of text in the JSON [uri http://www.json.org/] data
exchange format as specified in
RFC 4627 [uri http://www.ietf.org/rfc/rfc4627.txt].

[section COMMANDS]

[list_begin definitions]

[call [cmd ::json::write] [method indented]]

This method returns the current state of the indentation setting.


[call [cmd ::json::write] [method indented] [arg flag]]

This and the method [method aligned] configure the layout of the JSON
generated by the package.

[para]

If this [arg flag] is set (default) the package will break the
generated JSON code across lines and indent it according to its inner
structure, with each key of an object on a separate line.

[para]

If this flag is not set, the whole JSON object will be written on a
single line, with minimum spacing between all elements.


[call [cmd ::json::write] [method aligned]]

This method returns the current state of the alignment setting.


[call [cmd ::json::write] [method aligned] [arg flag]]


This and the method [method indented] configure the layout of the JSON
generated by the package.

[para]

If this [arg flag] is set (default) the package ensures that the
values for the keys in an object are vertically aligned with each
other, for a nice table effect. To make this work this also implies
that [var indented] is set as well.

[para]

If this flag is not set, the output is formatted as per the value of
[var indented], without trying to align the values for object keys.


[call [cmd ::json::write] [method string] [arg s]]

This method takes the string [arg s] and returns it properly quoted
for JSON as its result.


[call [cmd ::json::write] [method array] [arg arg]...]

This method takes a series of JSON formatted arguments and returns
them as a properly formatted JSON array as its result.


[call [cmd ::json::write] [method object] [arg key] [arg value]...]

This method takes a series of key/value arguments, the values already
formatted for JSON, and returns them as a properly formatted JSON
object as its result, with the keys formatted as JSON strings.


[list_end]
[para]

[vset CATEGORY json]
[include ../doctools2base/include/feedback.inc]
[manpage_end]