| 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 // Pure Dart implementation of JSON protocol. | 7 // Pure Dart implementation of JSON protocol. |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Utility class to parse JSON and serialize objects to JSON. | 10 * Utility class to parse JSON and serialize objects to JSON. |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 num _parseNumber() { | 275 num _parseNumber() { |
| 276 if (!_isToken(NUMBER_LITERAL)) _error("Expected number literal"); | 276 if (!_isToken(NUMBER_LITERAL)) _error("Expected number literal"); |
| 277 | 277 |
| 278 final int startPos = position; | 278 final int startPos = position; |
| 279 if (_isChar(MINUS)) position++; | 279 if (_isChar(MINUS)) position++; |
| 280 if (_isChar(CHAR_0)) { | 280 if (_isChar(CHAR_0)) { |
| 281 position++; | 281 position++; |
| 282 } else if (_isDigit()) { | 282 } else if (_isDigit()) { |
| 283 position++; | 283 position++; |
| 284 while (_isDigit()) position++; | 284 while (_isDigit()) position++; |
| 285 } else { |
| 286 _error("Expected digit when parsing number"); |
| 285 } | 287 } |
| 286 | 288 |
| 287 bool isInt = true; | 289 bool isInt = true; |
| 288 if (_isChar(DOT)) { | 290 if (_isChar(DOT)) { |
| 289 position++; | 291 position++; |
| 290 if (_isDigit()) { | 292 if (_isDigit()) { |
| 291 isInt = false; | 293 isInt = false; |
| 292 while (_isDigit()) position++; | 294 while (_isDigit()) position++; |
| 293 } else { | 295 } else { |
| 294 position--; // No digit, backtrack. | 296 position--; // No digit, backtrack. |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 }); | 507 }); |
| 506 _sb.add('}'); | 508 _sb.add('}'); |
| 507 _seen.removeLast(); | 509 _seen.removeLast(); |
| 508 return; | 510 return; |
| 509 | 511 |
| 510 default: | 512 default: |
| 511 throw const JsonUnsupportedObjectType(); | 513 throw const JsonUnsupportedObjectType(); |
| 512 } | 514 } |
| 513 } | 515 } |
| 514 } | 516 } |
| OLD | NEW |