| 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 final _ToEncodable _toEncodable; | 405 final _ToEncodable _toEncodable; |
| 406 final StringConversionSink _sink; | 406 final StringConversionSink _sink; |
| 407 bool _isDone = false; | 407 bool _isDone = false; |
| 408 | 408 |
| 409 _JsonEncoderSink(this._sink, this._toEncodable, this._indent); | 409 _JsonEncoderSink(this._sink, this._toEncodable, this._indent); |
| 410 | 410 |
| 411 /** | 411 /** |
| 412 * Encodes the given object [o]. | 412 * Encodes the given object [o]. |
| 413 * | 413 * |
| 414 * It is an error to invoke this method more than once on any instance. While | 414 * It is an error to invoke this method more than once on any instance. While |
| 415 * this makes the input effectly non-chunked the output will be generated in | 415 * this makes the input effectively non-chunked the output will be generated |
| 416 * a chunked way. | 416 * in a chunked way. |
| 417 */ | 417 */ |
| 418 void add(Object o) { | 418 void add(Object o) { |
| 419 if (_isDone) { | 419 if (_isDone) { |
| 420 throw new StateError("Only one call to add allowed"); | 420 throw new StateError("Only one call to add allowed"); |
| 421 } | 421 } |
| 422 _isDone = true; | 422 _isDone = true; |
| 423 ClosableStringSink stringSink = _sink.asStringSink(); | 423 ClosableStringSink stringSink = _sink.asStringSink(); |
| 424 _JsonStringStringifier.printOn(o, stringSink, _toEncodable, _indent); | 424 _JsonStringStringifier.printOn(o, stringSink, _toEncodable, _indent); |
| 425 stringSink.close(); | 425 stringSink.close(); |
| 426 } | 426 } |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 buffer.setRange(index, end, indent); | 1050 buffer.setRange(index, end, indent); |
| 1051 index = end; | 1051 index = end; |
| 1052 } else { | 1052 } else { |
| 1053 for (int i = 0; i < indentLength; i++) { | 1053 for (int i = 0; i < indentLength; i++) { |
| 1054 writeByte(indent[i]); | 1054 writeByte(indent[i]); |
| 1055 } | 1055 } |
| 1056 } | 1056 } |
| 1057 } | 1057 } |
| 1058 } | 1058 } |
| 1059 } | 1059 } |
| OLD | NEW |