| 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 /** | 5 /** |
| 6 * | 6 * |
| 7 * Encoders and decoders for converting between different data representations, | 7 * Encoders and decoders for converting between different data representations, |
| 8 * including JSON and UTF-8. | 8 * including JSON and UTF-8. |
| 9 * | 9 * |
| 10 * In addition to converters for common data representations, this library | 10 * In addition to converters for common data representations, this library |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 * stdout.writeln(line); | 49 * stdout.writeln(line); |
| 50 * }); | 50 * }); |
| 51 * | 51 * |
| 52 * See the documentation for the [Codec] and [Converter] classes | 52 * See the documentation for the [Codec] and [Converter] classes |
| 53 * for information about creating your own converters. | 53 * for information about creating your own converters. |
| 54 */ | 54 */ |
| 55 library dart.convert; | 55 library dart.convert; |
| 56 | 56 |
| 57 import 'dart:async'; | 57 import 'dart:async'; |
| 58 import 'dart:typed_data'; | 58 import 'dart:typed_data'; |
| 59 import 'dart:_js_helper' show patch; |
| 60 import 'dart:_foreign_helper' show JS; |
| 61 import 'dart:_interceptors' show JSExtendableArray; |
| 62 import 'dart:_internal' show MappedIterable, ListIterable; |
| 63 import 'dart:collection' show Maps, LinkedHashMap; |
| 59 | 64 |
| 60 part 'ascii.dart'; | 65 part 'ascii.dart'; |
| 61 part 'byte_conversion.dart'; | 66 part 'byte_conversion.dart'; |
| 62 part 'chunked_conversion.dart'; | 67 part 'chunked_conversion.dart'; |
| 63 part 'codec.dart'; | 68 part 'codec.dart'; |
| 64 part 'converter.dart'; | 69 part 'converter.dart'; |
| 65 part 'encoding.dart'; | 70 part 'encoding.dart'; |
| 66 part 'html_escape.dart'; | 71 part 'html_escape.dart'; |
| 67 part 'json.dart'; | 72 part 'json.dart'; |
| 68 part 'latin1.dart'; | 73 part 'latin1.dart'; |
| 69 part 'line_splitter.dart'; | 74 part 'line_splitter.dart'; |
| 70 part 'string_conversion.dart'; | 75 part 'string_conversion.dart'; |
| 71 part 'utf.dart'; | 76 part 'utf.dart'; |
| 72 import 'dart:_js_helper' show patch; | |
| 73 import 'dart:_foreign_helper' show JS; | |
| 74 import 'dart:_interceptors' show JSExtendableArray; | |
| 75 import 'dart:_internal' show MappedIterable, ListIterable; | |
| 76 import 'dart:collection' show Maps, LinkedHashMap; | |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * Walks the raw JavaScript value [json], replacing JavaScript Objects with | 79 * Walks the raw JavaScript value [json], replacing JavaScript Objects with |
| 80 * Maps. [json] is expected to be freshly allocated so elements can be replaced | 80 * Maps. [json] is expected to be freshly allocated so elements can be replaced |
| 81 * in-place. | 81 * in-place. |
| 82 */ | 82 */ |
| 83 _convertJsonToDart(json, reviver(key, value)) { | 83 _convertJsonToDart(json, reviver(key, value)) { |
| 84 assert(reviver != null); | 84 assert(reviver != null); |
| 85 walk(e) { | 85 walk(e) { |
| 86 // JavaScript null, string, number, bool are in the correct representation. | 86 // JavaScript null, string, number, bool are in the correct representation. |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 void close() { | 405 void close() { |
| 406 super.close(); | 406 super.close(); |
| 407 StringBuffer buffer = _stringSink; | 407 StringBuffer buffer = _stringSink; |
| 408 String accumulated = buffer.toString(); | 408 String accumulated = buffer.toString(); |
| 409 buffer.clear(); | 409 buffer.clear(); |
| 410 Object decoded = _parseJson(accumulated, _reviver); | 410 Object decoded = _parseJson(accumulated, _reviver); |
| 411 _sink.add(decoded); | 411 _sink.add(decoded); |
| 412 _sink.close(); | 412 _sink.close(); |
| 413 } | 413 } |
| 414 } | 414 } |
| OLD | NEW |