OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of dart.convert; | 5 part of dart.convert; |
6 | 6 |
7 /** | 7 /** |
8 * Error thrown by JSON serialization if an object cannot be serialized. | 8 * Error thrown by JSON serialization if an object cannot be serialized. |
9 * | 9 * |
10 * The [unsupportedObject] field holds that object that failed to be serialized. | 10 * The [unsupportedObject] field holds that object that failed to be serialized. |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 return new _JsonUtf8EncoderSink(sink._sink, _toEncodable, | 261 return new _JsonUtf8EncoderSink(sink._sink, _toEncodable, |
262 JsonUtf8Encoder._utf8Encode(indent), | 262 JsonUtf8Encoder._utf8Encode(indent), |
263 JsonUtf8Encoder.DEFAULT_BUFFER_SIZE); | 263 JsonUtf8Encoder.DEFAULT_BUFFER_SIZE); |
264 } | 264 } |
265 return new _JsonEncoderSink(sink, _toEncodable, indent); | 265 return new _JsonEncoderSink(sink, _toEncodable, indent); |
266 } | 266 } |
267 | 267 |
268 // Override the base class's bind, to provide a better type. | 268 // Override the base class's bind, to provide a better type. |
269 Stream<String> bind(Stream<Object> stream) => super.bind(stream); | 269 Stream<String> bind(Stream<Object> stream) => super.bind(stream); |
270 | 270 |
271 Converter<Object, dynamic/*=T*/> fuse/*<T>*/( | 271 Converter<Object, T> fuse<T>(Converter<String, T> other) { |
272 Converter<String, dynamic/*=T*/> other) { | |
273 if (other is Utf8Encoder) { | 272 if (other is Utf8Encoder) { |
274 return new JsonUtf8Encoder(indent, _toEncodable) | 273 return new JsonUtf8Encoder(indent, _toEncodable) |
275 as dynamic/*=Converter<Object, T>*/; | 274 as dynamic/*=Converter<Object, T>*/; |
276 } | 275 } |
277 return super.fuse/*<T>*/(other); | 276 return super.fuse<T>(other); |
278 } | 277 } |
279 } | 278 } |
280 | 279 |
281 /** | 280 /** |
282 * Encoder that encodes a single object as a UTF-8 encoded JSON string. | 281 * Encoder that encodes a single object as a UTF-8 encoded JSON string. |
283 * | 282 * |
284 * This encoder works equivalently to first converting the object to | 283 * This encoder works equivalently to first converting the object to |
285 * a JSON string, and then UTF-8 encoding the string, but without | 284 * a JSON string, and then UTF-8 encoding the string, but without |
286 * creating an intermediate string. | 285 * creating an intermediate string. |
287 */ | 286 */ |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 buffer.setRange(index, end, indent); | 1058 buffer.setRange(index, end, indent); |
1060 index = end; | 1059 index = end; |
1061 } else { | 1060 } else { |
1062 for (int i = 0; i < indentLength; i++) { | 1061 for (int i = 0; i < indentLength; i++) { |
1063 writeByte(indent[i]); | 1062 writeByte(indent[i]); |
1064 } | 1063 } |
1065 } | 1064 } |
1066 } | 1065 } |
1067 } | 1066 } |
1068 } | 1067 } |
OLD | NEW |