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 im‐
62              plies 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 re‐
74              turns 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
83       To parse json, instead of writing it, see package json.
84

BUGS, IDEAS, FEEDBACK

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

KEYWORDS

101       data exchange, exchange format, javascript, json
102

CATEGORY

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