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

NAME

8       json::write - JSON generation
9

SYNOPSIS

11       package require Tcl  8.5
12
13       package require json::write  ?1.0.3?
14
15       ::json::write indented
16
17       ::json::write indented flag
18
19       ::json::write aligned
20
21       ::json::write aligned flag
22
23       ::json::write string s
24
25       ::json::write array arg...
26
27       ::json::write object key value...
28
29______________________________________________________________________________
30

DESCRIPTION

32       The  json::write package provides a simple Tcl-only library for genera‐
33       tion of text in the JSON http://www.json.org/ data exchange  format  as
34       specified in RFC 4627 http://www.ietf.org/rfc/rfc4627.txt.
35

COMMANDS

37       ::json::write indented
38              This  method  returns  the current state of the indentation set‐
39              ting.
40
41       ::json::write indented flag
42              This and the method aligned configure the  layout  of  the  JSON
43              generated by the package.
44
45              If  this flag is set (default) the package will break the gener‐
46              ated JSON code across lines and indent it according to its inner
47              structure, with each key of an object on a separate line.
48
49              If  this  flag is not set, the whole JSON object will be written
50              on a single line, with minimum spacing between all elements.
51
52       ::json::write aligned
53              This method returns the current state of the alignment setting.
54
55       ::json::write aligned flag
56              This and the method indented configure the layout  of  the  JSON
57              generated by the package.
58
59              If  this flag is set (default) the package ensures that the val‐
60              ues for the keys in an object are vertically aligned  with  each
61              other,  for  a  nice  table  effect. To make this work this also
62              implies that indented is set as well.
63
64              If this flag is not set, the output  is  formatted  as  per  the
65              value of indented, without trying to align the values for object
66              keys.
67
68       ::json::write string s
69              This method takes the string s and returns  it  properly  quoted
70              for JSON as its result.
71
72       ::json::write array arg...
73              This  method  takes  a  series  of  JSON formatted arguments and
74              returns them as a properly formatted JSON array as its result.
75
76       ::json::write object key value...
77              This method takes a series of key/value  arguments,  the  values
78              already  formatted for JSON, and returns them as a properly for‐
79              matted JSON object as its result, with  the  keys  formatted  as
80              JSON strings.
81

BUGS, IDEAS, FEEDBACK

83       This  document,  and the package it describes, will undoubtedly contain
84       bugs and other problems.  Please report such in the  category  json  of
85       the  Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please
86       also report any ideas for enhancements you may have for either  package
87       and/or documentation.
88
89       When proposing code changes, please provide unified diffs, i.e the out‐
90       put of diff -u.
91
92       Note further that  attachments  are  strongly  preferred  over  inlined
93       patches.  Attachments  can  be  made  by  going to the Edit form of the
94       ticket immediately after its creation, and  then  using  the  left-most
95       button in the secondary navigation bar.
96

KEYWORDS

98       data exchange, exchange format, javascript, json
99

CATEGORY

101       CGI programming
102
104       Copyright (c) 2009-2013 Andreas Kupries <andreas_kupries@sourceforge.net>
105
106
107
108
109tcllib                               1.0.3                      json::write(n)
Impressum