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

Side by Side Diff: chrome/test/webdriver/commands/response.cc

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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/json/json_writer_unittest.cc ('k') | chrome/test/webdriver/webdriver_logging.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/webdriver/commands/response.h" 5 #include "chrome/test/webdriver/commands/response.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 11
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 void Response::SetField(const std::string& key, Value* value) { 64 void Response::SetField(const std::string& key, Value* value) {
65 data_.Set(key, value); 65 data_.Set(key, value);
66 } 66 }
67 67
68 const Value* Response::GetDictionary() const { 68 const Value* Response::GetDictionary() const {
69 return &data_; 69 return &data_;
70 } 70 }
71 71
72 std::string Response::ToJSON() const { 72 std::string Response::ToJSON() const {
73 std::string json; 73 std::string json;
74 base::JSONWriter::Write(&data_, false, &json); 74 // The |Value| classes do not support int64 and in rare cases we need to
75 // return one. We do this by using a double and passing in the special
76 // option so that the JSONWriter doesn't add '.0' to the end and confuse
77 // the WebDriver client.
78 base::JSONWriter::WriteWithOptions(
79 &data_, false,
80 base::JSONWriter::OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION, &json);
75 return json; 81 return json;
76 } 82 }
77 83
78 } // namespace webdriver 84 } // namespace webdriver
OLDNEW
« no previous file with comments | « base/json/json_writer_unittest.cc ('k') | chrome/test/webdriver/webdriver_logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698