| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #library("json"); | 5 #library("json"); |
| 6 | 6 |
| 7 // TODO(devoncarew): this file is a copy of client/json/dart_json.dart and shoul
d be deleted as | 7 // TODO(devoncarew): this file is a copy of client/json/dart_json.dart and shoul
d be deleted as |
| 8 // soon as it is no longer referenced from frog_server.dart. | 8 // soon as it is no longer referenced from frog_server.dart. |
| 9 | 9 |
| 10 // Pure Dart implementation of JSON protocol. | 10 // Pure Dart implementation of JSON protocol. |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 final int length = s.length; | 509 final int length = s.length; |
| 510 bool needsEscape = false; | 510 bool needsEscape = false; |
| 511 final charCodes = new List<int>(); | 511 final charCodes = new List<int>(); |
| 512 for (int i = 0; i < length; i++) { | 512 for (int i = 0; i < length; i++) { |
| 513 int charCode = s.charCodeAt(i); | 513 int charCode = s.charCodeAt(i); |
| 514 if (_needsEscape(charCode)) { | 514 if (_needsEscape(charCode)) { |
| 515 charCodes.add(JsonTokenizer.BACKSLASH); | 515 charCodes.add(JsonTokenizer.BACKSLASH); |
| 516 needsEscape = true; | 516 needsEscape = true; |
| 517 | 517 |
| 518 if (JsonTokenizer.NEW_LINE == charCode) { | 518 if (JsonTokenizer.NEW_LINE == charCode) { |
| 519 charCode = N_SMALL; | 519 charCode = JsonTokenizer.N_SMALL; |
| 520 } else if (JsonTokenizer.LINE_FEED == charCode) { | 520 } else if (JsonTokenizer.LINE_FEED == charCode) { |
| 521 charCode = R_SMALL; | 521 charCode = JsonTokenizer.R_SMALL; |
| 522 } | 522 } |
| 523 } | 523 } |
| 524 charCodes.add(charCode); | 524 charCodes.add(charCode); |
| 525 } | 525 } |
| 526 sb.add(needsEscape ? new String.fromCharCodes(charCodes) : s); | 526 sb.add(needsEscape ? new String.fromCharCodes(charCodes) : s); |
| 527 } | 527 } |
| 528 | 528 |
| 529 void _checkCycle(final object) { | 529 void _checkCycle(final object) { |
| 530 // TODO: use Iterables. | 530 // TODO: use Iterables. |
| 531 for (int i = 0; i < _seen.length; i++) { | 531 for (int i = 0; i < _seen.length; i++) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 }); | 595 }); |
| 596 _sb.add('}'); | 596 _sb.add('}'); |
| 597 _seen.removeLast(); | 597 _seen.removeLast(); |
| 598 return; | 598 return; |
| 599 | 599 |
| 600 default: | 600 default: |
| 601 throw const JsonUnsupportedObjectType(); | 601 throw const JsonUnsupportedObjectType(); |
| 602 } | 602 } |
| 603 } | 603 } |
| 604 } | 604 } |
| OLD | NEW |