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

Unified Diff: base/json/json_writer.h

Issue 9016024: Add option for not adding '.0' to the end of doubles that have no fractional (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 9 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 | « no previous file | base/json/json_writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_writer.h
diff --git a/base/json/json_writer.h b/base/json/json_writer.h
index 88c7d58101bf5ca69b5c53a4c233564d828d97ac..43f8e564f327cdc07b4c5c5a7f753f7f66d715d1 100644
--- a/base/json/json_writer.h
+++ b/base/json/json_writer.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -25,7 +25,13 @@ class BASE_EXPORT JSONWriter {
// For values of binary type, the value (and key if within a dictionary)
// will be omitted from the output.
- OPTIONS_OMIT_BINARY_VALUES = 1 << 1
+ OPTIONS_OMIT_BINARY_VALUES = 1 << 1,
+
+ // This option instructs the writer to write doubles that have no fractional
+ // part as a normal integer (i.e., without using exponential notation
+ // or appending a '.0') as long as the value is within the range of a
+ // 64-bit int.
+ OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION = 1 << 2
};
// Given a root node, generates a JSON string and puts it into |json|.
@@ -53,7 +59,8 @@ class BASE_EXPORT JSONWriter {
// Called recursively to build the JSON string. Whe completed, value is
// json_string_ will contain the JSON.
void BuildJSONString(const Value* const node, int depth, bool escape,
- bool ignore_binary_values);
+ bool ignore_binary_values,
+ bool omit_double_type_preservation);
// Appends a quoted, escaped, version of (UTF-8) str to json_string_.
void AppendQuotedString(const std::string& str);
« no previous file with comments | « no previous file | base/json/json_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698