source: branches/branch-1.4/docs/api/zoo-format-json.txt @ 624

Last change on this file since 624 was 348, checked in by neteler, 13 years ago

set correctly svn propset

  • Property svn:eol-style set to native
  • Property svn:keywords set to HeadURL Date Author Id Rev
  • Property svn:mime-type set to text/plain
File size: 6.6 KB
Line 
1.. _api-zoo-format-json:
2
3ZOO.Format.JSON
4===============
5
6A parser to read/write JSON safely.
7
8Inherits from
9
10- :ref:`ZOO.Format <api-zoo-format>`
11
12Properties     
13----------
14
15.. list-table::
16   :widths: 12 50
17   :header-rows: 1
18
19   * - NAME
20     - DESCRIPTION
21   * - :ref:`indent <indent>`
22     - {String} For "pretty" printing, the indent string will be used once for each indentation level.
23   * - :ref:`space <space>`
24     - {String} For "pretty" printing, the space string will be used after the ":" separating a name/value pair.
25   * - :ref:`newline <newline>`
26     - {String} For "pretty" printing, the newline string will be used at the end of each name/value pair or array item.
27   * - :ref:`level <level>`
28     - {Integer} For "pretty" printing, this is incremented/decremented during serialization. 
29   * - :ref:`pretty <pretty>`
30     - {Boolean} Serialize with extra whitespace for structure.   
31     
32Functions       
33---------
34
35.. list-table::
36   :widths: 14 50
37   :header-rows: 1
38
39   * - NAME
40     - DESCRIPTION
41   * - :ref:`ZOO.Format.JSON <ZOO.Format.JSON>`
42     - Create a new parser for JSON.
43   * - :ref:`read <read>`
44     - Deserialize a json string.
45   * - :ref:`write <write>`
46     - Serialize an object into a JSON string.
47   * - :ref:`writeIndent <writeIndent>`
48     - Output an indentation string depending on the indentation level. 
49   * - :ref:`writeNewline <writeNewline>`
50     - Output a string representing a newline if in pretty printing mode.   
51   * - :ref:`writeSpace <writeSpace>`
52     - Output a string representing a space if in pretty printing mode.
53     
54Serialize Properties   
55--------------------
56
57.. list-table::
58   :widths: 14 50
59   :header-rows: 1
60
61   * - NAME
62     - DESCRIPTION
63   * - :ref:`serialize <serialize>`
64     - Object with properties corresponding to the serializable data types.
65     
66Serialize Functions     
67-------------------
68
69.. list-table::
70   :widths: 14 50
71   :header-rows: 1
72
73   * - NAME
74     - DESCRIPTION
75   * - :ref:`serialize.object <serialize.object>`
76     - Transform an object into a JSON string.
77   * - :ref:`serialize.array <serialize.array>`
78     - Transform an array into a JSON string.
79   * - :ref:`serialize.string <serialize.string>`
80     - Transform a string into a JSON string.
81   * - :ref:`serialize.number <serialize.number>`
82     - Transform a number into a JSON string. 
83   * - :ref:`serialize.boolean <serialize.boolean>`
84     - Transform a boolean into a JSON string.   
85   * - :ref:`serialize.date <serialize.date>`
86     - Transform a date into a JSON string.     
87       
88**Properties**
89
90.. _indent:   
91
92indent 
93  ``{String}`` For "pretty" printing, the indent string will be used once for each indentation level.
94 
95.. _space:     
96 
97space   
98  ``{String}`` For "pretty" printing, the space string will be used after the ":" separating a name/value pair.
99 
100.. _newline:       
101 
102newline
103  ``{String}`` For "pretty" printing, the newline string will be used at the end of each name/value pair or array item.
104 
105.. _level:       
106 
107level   
108  ``{Integer}`` For "pretty" printing, this is incremented/decremented during serialization.
109 
110.. _pretty:         
111 
112pretty 
113  ``{Boolean}`` Serialize with extra whitespace for structure. This is set by the :ref:`write <write>` method.
114 
115**Functions**
116
117.. _ZOO.Format.JSON:         
118
119ZOO.Format.JSON
120  Create a new parser for JSON.
121
122  *Parameters*
123 
124  ``options {Object}`` An optional object whose properties will be set on this instance.
125 
126.. _read:           
127 
128read   
129  ::
130 
131    read: function(json,filter)
132
133  Deserialize a json string.
134
135  *Parameters*
136 
137  | ``json {String}`` A JSON string
138  | ``filter {Function}`` A function which will be called for every key and value at every level of the final result.  Each value will be replaced by the result of the filter function.  This can be used to reform generic objects into instances of classes, or to transform date strings into Date objects.
139
140  *Returns*
141
142  ``{Object}`` An object, array, string, or number.
143 
144.. _write:             
145 
146write   
147  ::
148 
149    write: function(value,pretty)
150
151  Serialize an object into a JSON string.
152
153  *Parameters*
154 
155  | ``value {String}`` The object, array, string, number, boolean or date to be serialized.
156  | ``pretty {Boolean}`` Structure the output with newlines and indentation.  Default is false.
157
158  *Returns*
159
160  ``{String}`` The JSON string representation of the input value. 
161 
162.. _writeIndent:               
163 
164writeIndent     
165  ::
166 
167    writeIndent: function()
168
169  Output an indentation string depending on the indentation level.
170 
171  *Returns*
172
173  ``{String}`` An appropriate indentation string.
174 
175.. _writeNewline:               
176 
177writeNewline   
178  ::
179 
180    writeNewline: function()
181
182  Output a string representing a newline if in pretty printing mode.
183 
184  *Returns*
185
186  ``{String}`` A string representing a new line.
187 
188.. _writeSpace:               
189 
190writeSpace     
191  ::
192 
193    writeSpace: function()
194
195  Output a string representing a space if in pretty printing mode. 
196
197  *Returns*
198
199  ``{String}`` A space.
200 
201**Serialize Properties**
202
203.. _serialize:               
204
205serialize       
206  Object with properties corresponding to the serializable data types. Property
207  values are functions that do the actual serializing.
208 
209**Serialize Functions**
210
211.. _serialize.object:               
212
213serialize.object       
214  Transform an object into a JSON string.
215
216  *Parameters*
217
218  ``object {Object}`` The object to be serialized.
219 
220  *Returns*
221
222  ``{String}`` A JSON string representing the object.
223 
224.. _serialize.array:                 
225 
226serialize.array
227  Transform an array into a JSON string.
228
229  *Parameters*
230 
231  ``array {Array}`` The array to be serialized
232
233  *Returns*
234
235  ``{String}`` A JSON string representing the array.
236 
237.. _serialize.string:                   
238 
239serialize.string       
240  Transform a string into a JSON string.
241
242  *Parameters*
243 
244  ``string {String}`` The string to be serialized
245
246  *Returns*
247
248  ``{String}`` A JSON string representing the string.
249 
250.. _serialize.number:                     
251 
252serialize.number       
253  Transform a number into a JSON string.
254
255  *Parameters*
256 
257  ``number {Number}`` The number to be serialized.
258 
259  *Returns*
260
261  ``{String}`` A JSON string representing the number. 
262 
263.. _serialize.boolean:                       
264 
265serialize.boolean       
266  Transform a boolean into a JSON string.
267
268  *Parameters*
269 
270  ``bool {Boolean}`` The boolean to be serialized.
271
272  *Returns*
273
274  ``{String}`` A JSON string representing the boolean.
275 
276.. _serialize.date:                         
277 
278serialize.date 
279  Transform a date into a JSON string.
280
281  *Parameters*
282 
283  ``date {Date}`` The date to be serialized.
284
285  *Returns*
286
287  ``{String}`` A JSON string representing the date.
Note: See TracBrowser for help on using the repository browser.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png