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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 static final int CHAR_2 = 50; | 73 static final int CHAR_2 = 50; |
74 static final int CHAR_3 = 51; | 74 static final int CHAR_3 = 51; |
75 static final int CHAR_4 = 52; | 75 static final int CHAR_4 = 52; |
76 static final int CHAR_5 = 53; | 76 static final int CHAR_5 = 53; |
77 static final int CHAR_6 = 54; | 77 static final int CHAR_6 = 54; |
78 static final int CHAR_7 = 55; | 78 static final int CHAR_7 = 55; |
79 static final int CHAR_8 = 56; | 79 static final int CHAR_8 = 56; |
80 static final int CHAR_9 = 57; | 80 static final int CHAR_9 = 57; |
81 static final int COLON = 58; | 81 static final int COLON = 58; |
82 static final int CHAR_CAPITAL_E = 69; | 82 static final int CHAR_CAPITAL_E = 69; |
83 static final int CHAR_CAPITAL_U = 85; | |
83 static final int LBRACKET = 91; | 84 static final int LBRACKET = 91; |
84 static final int BACKSLASH = 92; | 85 static final int BACKSLASH = 92; |
85 static final int RBRACKET = 93; | 86 static final int RBRACKET = 93; |
86 static final int CHAR_B = 98; | 87 static final int CHAR_B = 98; |
87 static final int CHAR_E = 101; | 88 static final int CHAR_E = 101; |
88 static final int CHAR_F = 102; | 89 static final int CHAR_F = 102; |
89 static final int CHAR_N = 110; | 90 static final int CHAR_N = 110; |
90 static final int CHAR_R = 114; | 91 static final int CHAR_R = 114; |
91 static final int CHAR_T = 116; | 92 static final int CHAR_T = 116; |
92 static final int CHAR_U = 117; | 93 static final int CHAR_U = 117; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 _error('Invalid unicode esacape sequence'); | 289 _error('Invalid unicode esacape sequence'); |
289 } | 290 } |
290 final codeString = json.substring(position + 1, position + 5); | 291 final codeString = json.substring(position + 1, position + 5); |
291 try { | 292 try { |
292 c = Math.parseInt('0x${codeString}'); | 293 c = Math.parseInt('0x${codeString}'); |
293 } catch (var e) { | 294 } catch (var e) { |
294 _error('Invalid unicode esacape sequence'); | 295 _error('Invalid unicode esacape sequence'); |
295 } | 296 } |
296 position += 4; | 297 position += 4; |
297 break; | 298 break; |
299 case CHAR_CAPITAL_U: | |
300 // Non-standard 32 bit characters of format \UHHHHHHHH. | |
siva
2012/07/18 17:11:31
What do you mean by non-standard here? not part of
hausner
2012/07/18 22:20:36
I reverted the changes in this file, they are no l
| |
301 if (position + 9 > length) { | |
302 _error('Invalid unicode esacape sequence'); | |
303 } | |
304 final codeString = json.substring(position + 1, position + 9); | |
305 try { | |
306 c = Math.parseInt('0x${codeString}'); | |
307 } catch (var e) { | |
308 _error('Invalid unicode esacape sequence'); | |
309 } | |
310 position += 8; | |
311 break; | |
298 default: | 312 default: |
299 _error('Invalid esacape sequence in string literal'); | 313 _error('Invalid esacape sequence in string literal'); |
300 } | 314 } |
301 } | 315 } |
302 charCodes.add(c); | 316 charCodes.add(c); |
303 position++; | 317 position++; |
304 } | 318 } |
305 | 319 |
306 return new String.fromCharCodes(charCodes); | 320 return new String.fromCharCodes(charCodes); |
307 } | 321 } |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 first = false; | 560 first = false; |
547 }); | 561 }); |
548 _sb.add('}'); | 562 _sb.add('}'); |
549 _seen.removeLast(); | 563 _seen.removeLast(); |
550 return; | 564 return; |
551 } else { | 565 } else { |
552 throw const JsonUnsupportedObjectType(); | 566 throw const JsonUnsupportedObjectType(); |
553 } | 567 } |
554 } | 568 } |
555 } | 569 } |
OLD | NEW |