Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: sdk/lib/json/json_base.dart

Issue 12313069: Revert "Use browsers JSON.parse for parsing JSON (#3)" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/libraries.dart ('k') | tests/corelib/corelib.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // JSON parsing and serialization. 5 // JSON parsing and serialization.
6 6
7 /** 7 /**
8 * Error thrown by JSON serialization if an object cannot be serialized. 8 * Error thrown by JSON serialization if an object cannot be serialized.
9 * 9 *
10 * The [unsupportedObject] field holds that object that failed to be serialized. 10 * The [unsupportedObject] field holds that object that failed to be serialized.
(...skipping 29 matching lines...) Expand all
40 * JSON values. 40 * JSON values.
41 * 41 *
42 * The optional [revivier] function, if provided, is called once for each 42 * The optional [revivier] function, if provided, is called once for each
43 * object or list property parsed. The arguments are the property name 43 * object or list property parsed. The arguments are the property name
44 * ([String]) or list index ([int]), and the value is the parsed value. 44 * ([String]) or list index ([int]), and the value is the parsed value.
45 * The return value of the revivier will be used as the value of that property 45 * The return value of the revivier will be used as the value of that property
46 * instead the parsed value. 46 * instead the parsed value.
47 * 47 *
48 * Throws [FormatException] if the input is not valid JSON text. 48 * Throws [FormatException] if the input is not valid JSON text.
49 */ 49 */
50 external parse(String json, [reviver(var key, var value)]); 50 parse(String json, [reviver(var key, var value)]) {
51
52 _parse(String json, reviver(var key, var value)) {
53 BuildJsonListener listener; 51 BuildJsonListener listener;
54 if (reviver == null) { 52 if (reviver == null) {
55 listener = new BuildJsonListener(); 53 listener = new BuildJsonListener();
56 } else { 54 } else {
57 listener = new ReviverJsonListener(reviver); 55 listener = new ReviverJsonListener(reviver);
58 } 56 }
59 new JsonParser(json, listener).parse(); 57 new JsonParser(json, listener).parse();
60 return listener.result; 58 return listener.result;
61 } 59 }
62 60
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 first = false; 793 first = false;
796 }); 794 });
797 sb.add('}'); 795 sb.add('}');
798 seen.removeLast(); 796 seen.removeLast();
799 return true; 797 return true;
800 } else { 798 } else {
801 return false; 799 return false;
802 } 800 }
803 } 801 }
804 } 802 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/libraries.dart ('k') | tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698