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

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

Issue 17580014: dart:convert library. Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update 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
« no previous file with comments | « sdk/lib/codec/encoding.dart ('k') | sdk/lib/convert/byte_converter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.codec;
6
7 final JSON = new JsonCodec();
8
9 class JsonCodec extends Codec<Object, String> {
10 const JsonCodec();
11 factory JsonCodec.withReviver(reviver(var key, var value)) =
12 _ReviverJsonCodec;
13
14 String encode(Object o) {
15 return encoder.convert(o);
16 }
17 Object decode(String str, {reviver(var key, var value)}) {
18 return new JsonDecoder(reviver).convert(str);
19 }
20
21 JsonEncoder get encoder => new JsonEncoder();
22 JsonDecoder get decoder => new JsonDecoder(null);
23 }
24
25 class _ReviverJsonCodec extends JsonCodec {
26 final Function _reviver;
27 _ReviverJsonCodec(this._reviver);
28
29 Object decode(String str, {reviver(var key, var value)}) {
30 reviver = reviver == null ? _reviver : reviver;
31 return new JsonDecoder(reviver).convert(str);
32 }
33
34 JsonDecoder get decoder => new JsonDecoder(_reviver);
35 }
OLDNEW
« no previous file with comments | « sdk/lib/codec/encoding.dart ('k') | sdk/lib/convert/byte_converter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698