OLD | NEW |
1 // Copyright (c) 2012 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 "base/json/json_writer.h" | 5 #include "base/json/json_writer.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 | 16 |
17 #if defined(OS_WIN) | |
18 const char kPrettyPrintLineEnding[] = "\r\n"; | |
19 #else | |
20 const char kPrettyPrintLineEnding[] = "\n"; | 17 const char kPrettyPrintLineEnding[] = "\n"; |
21 #endif | |
22 | 18 |
23 // static | 19 // static |
24 bool JSONWriter::Write(const Value& node, std::string* json) { | 20 bool JSONWriter::Write(const Value& node, std::string* json) { |
25 return WriteWithOptions(node, 0, json); | 21 return WriteWithOptions(node, 0, json); |
26 } | 22 } |
27 | 23 |
28 // static | 24 // static |
29 bool JSONWriter::WriteWithOptions(const Value& node, | 25 bool JSONWriter::WriteWithOptions(const Value& node, |
30 int options, | 26 int options, |
31 std::string* json) { | 27 std::string* json) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 } | 195 } |
200 NOTREACHED(); | 196 NOTREACHED(); |
201 return false; | 197 return false; |
202 } | 198 } |
203 | 199 |
204 void JSONWriter::IndentLine(size_t depth) { | 200 void JSONWriter::IndentLine(size_t depth) { |
205 json_string_->append(depth * 3U, ' '); | 201 json_string_->append(depth * 3U, ' '); |
206 } | 202 } |
207 | 203 |
208 } // namespace base | 204 } // namespace base |
OLD | NEW |