OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_writer.h" | 5 #include "base/json_writer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "base/string_escape.h" | 10 #include "base/string_escape.h" |
| 11 #include "base/utf_string_conversions.h" |
11 | 12 |
12 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
13 static const char kPrettyPrintLineEnding[] = "\r\n"; | 14 static const char kPrettyPrintLineEnding[] = "\r\n"; |
14 #else | 15 #else |
15 static const char kPrettyPrintLineEnding[] = "\n"; | 16 static const char kPrettyPrintLineEnding[] = "\n"; |
16 #endif | 17 #endif |
17 | 18 |
18 /* static */ | 19 /* static */ |
19 void JSONWriter::Write(const Value* const node, | 20 void JSONWriter::Write(const Value* const node, |
20 bool pretty_print, | 21 bool pretty_print, |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 string_escape::JsonDoubleQuote(WideToUTF16Hack(str), | 189 string_escape::JsonDoubleQuote(WideToUTF16Hack(str), |
189 true, | 190 true, |
190 json_string_); | 191 json_string_); |
191 } | 192 } |
192 | 193 |
193 void JSONWriter::IndentLine(int depth) { | 194 void JSONWriter::IndentLine(int depth) { |
194 // It may be faster to keep an indent string so we don't have to keep | 195 // It may be faster to keep an indent string so we don't have to keep |
195 // reallocating. | 196 // reallocating. |
196 json_string_->append(std::string(depth * 3, ' ')); | 197 json_string_->append(std::string(depth * 3, ' ')); |
197 } | 198 } |
OLD | NEW |