| 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 part of common; | 5 part of common; |
| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 break; | 192 break; |
| 193 case 't': | 193 case 't': |
| 194 c = TAB; | 194 c = TAB; |
| 195 break; | 195 break; |
| 196 case 'u': | 196 case 'u': |
| 197 if (_pos + 5 > _len) { | 197 if (_pos + 5 > _len) { |
| 198 throw 'Invalid unicode esacape sequence: \\' + | 198 throw 'Invalid unicode esacape sequence: \\' + |
| 199 _s.substring(_pos, _len); | 199 _s.substring(_pos, _len); |
| 200 } | 200 } |
| 201 final codeString = _s.substring(_pos + 1, _pos + 5); | 201 final codeString = _s.substring(_pos + 1, _pos + 5); |
| 202 c = Math.parseInt('0x' + codeString); | 202 c = int.parse('0x' + codeString); |
| 203 if (c >= 128) { | 203 if (c >= 128) { |
| 204 // TODO(jmessery): the VM doesn't support 2-byte strings yet | 204 // TODO(jmessery): the VM doesn't support 2-byte strings yet |
| 205 // see runtime/lib/string.cc:49 | 205 // see runtime/lib/string.cc:49 |
| 206 // So instead we replace these characters with '?' | 206 // So instead we replace these characters with '?' |
| 207 c = '?'.charCodeAt(0); | 207 c = '?'.charCodeAt(0); |
| 208 } | 208 } |
| 209 _pos += 4; | 209 _pos += 4; |
| 210 break; | 210 break; |
| 211 default: | 211 default: |
| 212 throw 'Invalid esacape sequence: \\' + _s[_pos]; | 212 throw 'Invalid esacape sequence: \\' + _s[_pos]; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 _pos++; | 247 _pos++; |
| 248 c = _s.charCodeAt(_pos); | 248 c = _s.charCodeAt(_pos); |
| 249 if (c == PLUS || c == MINUS) { | 249 if (c == PLUS || c == MINUS) { |
| 250 _pos++; | 250 _pos++; |
| 251 } | 251 } |
| 252 skipDigits(); | 252 skipDigits(); |
| 253 } | 253 } |
| 254 | 254 |
| 255 final String body = _s.substring(startPos, _pos); | 255 final String body = _s.substring(startPos, _pos); |
| 256 return new JsonToken.number( | 256 return new JsonToken.number( |
| 257 isInteger ? Math.parseInt(body) : Math.parseDouble(body)); | 257 isInteger ? int.parse(body) : double.parse(body)); |
| 258 | 258 |
| 259 case cur == LBRACE: | 259 case cur == LBRACE: |
| 260 _pos++; | 260 _pos++; |
| 261 return new JsonToken.atom(JsonToken.LBRACE); | 261 return new JsonToken.atom(JsonToken.LBRACE); |
| 262 | 262 |
| 263 case cur == RBRACE: | 263 case cur == RBRACE: |
| 264 _pos++; | 264 _pos++; |
| 265 return new JsonToken.atom(JsonToken.RBRACE); | 265 return new JsonToken.atom(JsonToken.RBRACE); |
| 266 | 266 |
| 267 case cur == LBRACKET: | 267 case cur == LBRACKET: |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 _sb.add(','); | 562 _sb.add(','); |
| 563 } | 563 } |
| 564 }); | 564 }); |
| 565 _sb.add('}'); | 565 _sb.add('}'); |
| 566 return; | 566 return; |
| 567 } else { | 567 } else { |
| 568 throw const JsonUnsupportedObjectType(); | 568 throw const JsonUnsupportedObjectType(); |
| 569 } | 569 } |
| 570 } | 570 } |
| 571 } | 571 } |
| OLD | NEW |