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

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

Issue 19000006: First version of Codecs and Converters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revert sdk/lib/json change. Created 7 years, 5 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
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 part of dart.convert;
6
7 /**
8 * A [JsonEncoder] converts Json-objects to strings.
9 */
10 class JsonEncoder extends Converter<Object, String> {
11 JsonEncoder();
12
13 /**
14 * Converts the given Json-object [o] and returns its stringified
Lasse Reichstein Nielsen 2013/07/12 11:50:47 Specify whay "Json-object" is (JSON object). It's
floitsch 2013/07/12 16:09:15 copied the documentation from `stringify`.
15 * Json representation.
Lasse Reichstein Nielsen 2013/07/12 11:50:47 Json -> JSON. Drop "stringified", JSON is a string
floitsch 2013/07/12 16:09:15 removed.
16 */
17 String convert(Object o) => OLD_JSON_LIB.stringify(o);
18 }
19
20 typedef _Reviver(var key, var value);
21
22
23 /**
24 * A [JsonDecoder] parses Json strings and builds the corresponding
Lasse Reichstein Nielsen 2013/07/12 11:50:47 JSON strings JSON objects (if defined above)
floitsch 2013/07/12 16:09:15 Changed to "JSON strings and builds the correspond
25 * Json objects.
26 */
27 class JsonDecoder extends Converter<String, Object> {
28 final _Reviver _reviver;
29 /**
30 * Constructs a new JsonDecoder.
31 *
32 * The [reviver] may be `null`.
33 */
34 JsonDecoder(reviver(var key, var value)) : this._reviver = reviver;
35
36 /**
37 * Converts the given Json-string [input] to the corresponding object.
Lasse Reichstein Nielsen 2013/07/12 11:50:47 JSON string.
floitsch 2013/07/12 16:09:15 copied the original description.
38 *
39 * If `this` was initialized with a reviver, then the parsing operation
40 * invokes the reviver on every object or list property that has been parsed.
41 */
42 Object convert(String input) => OLD_JSON_LIB.parse(input, _reviver);
43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698