Changeset 175 for trunk/docs
- Timestamp:
- Apr 19, 2011, 11:32:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docs/api/zoo-format-json.txt
r165 r175 87 87 88 88 indent 89 {String}For "pretty" printing, the indent string will be used once for each indentation level.89 ``{String}`` For "pretty" printing, the indent string will be used once for each indentation level. 90 90 91 91 .. _space: 92 92 93 93 space 94 {String}For "pretty" printing, the space string will be used after the ":" separating a name/value pair.94 ``{String}`` For "pretty" printing, the space string will be used after the ":" separating a name/value pair. 95 95 96 96 .. _newline: 97 97 98 98 newline 99 {String}For "pretty" printing, the newline string will be used at the end of each name/value pair or array item.99 ``{String}`` For "pretty" printing, the newline string will be used at the end of each name/value pair or array item. 100 100 101 101 .. _level: 102 102 103 103 level 104 {Integer}For "pretty" printing, this is incremented/decremented during serialization.104 ``{Integer}`` For "pretty" printing, this is incremented/decremented during serialization. 105 105 106 106 .. _pretty: 107 107 108 108 pretty 109 {Boolean} Serialize with extra whitespace for structure.109 ``{Boolean}`` Serialize with extra whitespace for structure. This is set by the :ref:`write <write>` method. 110 110 111 111 **Functions** … … 115 115 ZOO.Format.JSON 116 116 Create a new parser for JSON. 117 118 *Parameters* 119 120 ``options {Object}`` An optional object whose properties will be set on this instance. 117 121 118 122 .. _read: 119 123 120 124 read 125 :: 126 127 read: function(json,filter) 128 121 129 Deserialize a json string. 130 131 *Parameters* 132 133 | ``json {String}`` A JSON string 134 | ``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. 135 136 *Returns* 137 138 ``{Object}`` An object, array, string, or number. 122 139 123 140 .. _write: 124 141 125 142 write 143 :: 144 145 write: function(value,pretty) 146 126 147 Serialize an object into a JSON string. 148 149 *Parameters* 150 151 | ``value {String}`` The object, array, string, number, boolean or date to be serialized. 152 | ``pretty {Boolean}`` Structure the output with newlines and indentation. Default is false. 153 154 *Returns* 155 156 ``{String}`` The JSON string representation of the input value. 127 157 128 158 .. _writeIndent: 129 159 130 160 writeIndent 161 :: 162 163 writeIndent: function() 164 131 165 Output an indentation string depending on the indentation level. 132 166 167 *Returns* 168 169 ``{String}`` An appropriate indentation string. 170 133 171 .. _writeNewline: 134 172 135 173 writeNewline 174 :: 175 176 writeNewline: function() 177 136 178 Output a string representing a newline if in pretty printing mode. 137 179 180 *Returns* 181 182 ``{String}`` A string representing a new line. 183 138 184 .. _writeSpace: 139 185 140 186 writeSpace 141 Output a string representing a space if in pretty printing mode. 187 :: 188 189 writeSpace: function() 190 191 Output a string representing a space if in pretty printing mode. 192 193 *Returns* 194 195 ``{String}`` A space. 142 196 143 197 **Serialize Properties** … … 146 200 147 201 serialize 148 Object with properties corresponding to the serializable data types. 202 Object with properties corresponding to the serializable data types. Property 203 values are functions that do the actual serializing. 149 204 150 205 **Serialize Functions** … … 154 209 serialize.object 155 210 Transform an object into a JSON string. 211 212 *Parameters* 213 214 ``object {Object}`` The object to be serialized. 215 216 *Returns* 217 218 ``{String}`` A JSON string representing the object. 156 219 157 220 .. _serialize.array: … … 159 222 serialize.array 160 223 Transform an array into a JSON string. 224 225 *Parameters* 226 227 ``array {Array}`` The array to be serialized 228 229 *Returns* 230 231 ``{String}`` A JSON string representing the array. 161 232 162 233 .. _serialize.string: … … 164 235 serialize.string 165 236 Transform a string into a JSON string. 237 238 *Parameters* 239 240 ``string {String}`` The string to be serialized 241 242 *Returns* 243 244 ``{String}`` A JSON string representing the string. 166 245 167 246 .. _serialize.number: … … 169 248 serialize.number 170 249 Transform a number into a JSON string. 250 251 *Parameters* 252 253 ``number {Number}`` The number to be serialized. 254 255 *Returns* 256 257 ``{String}`` A JSON string representing the number. 171 258 172 259 .. _serialize.boolean: … … 174 261 serialize.boolean 175 262 Transform a boolean into a JSON string. 263 264 *Parameters* 265 266 ``bool {Boolean}`` The boolean to be serialized. 267 268 *Returns* 269 270 ``{String}`` A JSON string representing the boolean. 176 271 177 272 .. _serialize.date: … … 179 274 serialize.date 180 275 Transform a date into a JSON string. 276 277 *Parameters* 278 279 ``date {Date}`` The date to be serialized. 280 281 *Returns* 282 283 ``{String}`` A JSON string representing the date.
Note: See TracChangeset
for help on using the changeset viewer.