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

Side by Side Diff: pkg/json/lib/json.dart

Issue 136373002: Fix JSON encoder accepting NaN and Infinity. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | « no previous file | pkg/json/test/json_test.dart » ('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 /** 5 /**
6 * Utilities for encoding and decoding JSON (JavaScript Object Notation) data. 6 * Utilities for encoding and decoding JSON (JavaScript Object Notation) data.
7 */ 7 */
8 8
9 library json; 9 library json;
10 10
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } 762 }
763 763
764 /** 764 /**
765 * Serializes a [num], [String], [bool], [Null], [List] or [Map] value. 765 * Serializes a [num], [String], [bool], [Null], [List] or [Map] value.
766 * 766 *
767 * Returns true if the value is one of these types, and false if not. 767 * Returns true if the value is one of these types, and false if not.
768 * If a value is both a [List] and a [Map], it's serialized as a [List]. 768 * If a value is both a [List] and a [Map], it's serialized as a [List].
769 */ 769 */
770 bool stringifyJsonValue(final object) { 770 bool stringifyJsonValue(final object) {
771 if (object is num) { 771 if (object is num) {
772 // TODO: use writeOn. 772 if (!object.isFinite) return false;
773 sink.write(numberToString(object)); 773 sink.write(numberToString(object));
774 return true; 774 return true;
775 } else if (identical(object, true)) { 775 } else if (identical(object, true)) {
776 sink.write('true'); 776 sink.write('true');
777 return true; 777 return true;
778 } else if (identical(object, false)) { 778 } else if (identical(object, false)) {
779 sink.write('false'); 779 sink.write('false');
780 return true; 780 return true;
781 } else if (object == null) { 781 } else if (object == null) {
782 sink.write('null'); 782 sink.write('null');
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 first = false; 818 first = false;
819 }); 819 });
820 sink.write('}'); 820 sink.write('}');
821 seen.remove(object); 821 seen.remove(object);
822 return true; 822 return true;
823 } else { 823 } else {
824 return false; 824 return false;
825 } 825 }
826 } 826 }
827 } 827 }
OLDNEW
« no previous file with comments | « no previous file | pkg/json/test/json_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698