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

Unified Diff: sdk/lib/json/json.dart

Issue 23554004: Made old dart:json library use convert to parse JSON. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addres review comments. Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/convert/json.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/json/json.dart
diff --git a/sdk/lib/json/json.dart b/sdk/lib/json/json.dart
index 5fd3a6ae20c0da9e60d0738eaa4e5959abbe91d7..a6b602b55142557897f548618266ffdfe24c62d3 100644
--- a/sdk/lib/json/json.dart
+++ b/sdk/lib/json/json.dart
@@ -8,48 +8,10 @@
library dart.json;
-// JSON parsing and serialization.
-
-/**
- * Error thrown by JSON serialization if an object cannot be serialized.
- *
- * The [unsupportedObject] field holds that object that failed to be serialized.
- *
- * If an object isn't directly serializable, the serializer calls the 'toJson'
- * method on the object. If that call fails, the error will be stored in the
- * [cause] field. If the call returns an object that isn't directly
- * serializable, the [cause] will be null.
- */
-class JsonUnsupportedObjectError extends Error {
- /** The object that could not be serialized. */
- final unsupportedObject;
- /** The exception thrown by object's [:toJson:] method, if any. */
- final cause;
-
- JsonUnsupportedObjectError(this.unsupportedObject, { this.cause });
-
- String toString() {
- if (cause != null) {
- return "Calling toJson method on object failed.";
- } else {
- return "Object toJson method returns non-serializable value.";
- }
- }
-}
-
-
-/**
- * Reports that an object could not be stringified due to cyclic references.
- *
- * An object that references itself cannot be serialized by [stringify].
- * When the cycle is detected, a [JsonCyclicError] is thrown.
- */
-class JsonCyclicError extends JsonUnsupportedObjectError {
- /** The first object that was detected as part of a cycle. */
- JsonCyclicError(Object object): super(object);
- String toString() => "Cyclic error in JSON stringify";
-}
+import "dart:convert";
+export "dart:convert" show JsonUnsupportedObjectError, JsonCyclicError;
+// JSON parsing and serialization.
/**
* Parses [json] and build the corresponding parsed JSON value.
@@ -66,17 +28,8 @@ class JsonCyclicError extends JsonUnsupportedObjectError {
*
* Throws [FormatException] if the input is not valid JSON text.
*/
-external parse(String json, [reviver(var key, var value)]);
-
-_parse(String json, reviver(var key, var value)) {
- BuildJsonListener listener;
- if (reviver == null) {
- listener = new BuildJsonListener();
- } else {
- listener = new ReviverJsonListener(reviver);
- }
- new JsonParser(json, listener).parse();
- return listener.result;
+parse(String json, [reviver(var key, var value)]) {
+ return JSON.decode(json, reviver: reviver);
}
/**
« no previous file with comments | « sdk/lib/convert/json.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698