OLD | NEW |
1 // Copyright (c) 2009 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/json_writer.h" | 5 #include "base/json/json_writer.h" |
6 | 6 |
7 #include "base/json/string_escape.h" | 7 #include "base/json/string_escape.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 for (DictionaryValue::key_iterator key_itr = dict->begin_keys(); | 150 for (DictionaryValue::key_iterator key_itr = dict->begin_keys(); |
151 key_itr != dict->end_keys(); | 151 key_itr != dict->end_keys(); |
152 ++key_itr) { | 152 ++key_itr) { |
153 if (key_itr != dict->begin_keys()) { | 153 if (key_itr != dict->begin_keys()) { |
154 json_string_->append(","); | 154 json_string_->append(","); |
155 if (pretty_print_) | 155 if (pretty_print_) |
156 json_string_->append(kPrettyPrintLineEnding); | 156 json_string_->append(kPrettyPrintLineEnding); |
157 } | 157 } |
158 | 158 |
159 Value* value = NULL; | 159 Value* value = NULL; |
160 bool result = dict->Get(*key_itr, &value); | 160 bool result = dict->GetWithoutPathExpansion(*key_itr, &value); |
161 DCHECK(result); | 161 DCHECK(result); |
162 | 162 |
163 if (pretty_print_) | 163 if (pretty_print_) |
164 IndentLine(depth + 1); | 164 IndentLine(depth + 1); |
165 AppendQuotedString(*key_itr); | 165 AppendQuotedString(*key_itr); |
166 if (pretty_print_) { | 166 if (pretty_print_) { |
167 json_string_->append(": "); | 167 json_string_->append(": "); |
168 } else { | 168 } else { |
169 json_string_->append(":"); | 169 json_string_->append(":"); |
170 } | 170 } |
(...skipping 20 matching lines...) Expand all Loading... |
191 JsonDoubleQuote(WideToUTF16Hack(str), true, json_string_); | 191 JsonDoubleQuote(WideToUTF16Hack(str), true, json_string_); |
192 } | 192 } |
193 | 193 |
194 void JSONWriter::IndentLine(int depth) { | 194 void JSONWriter::IndentLine(int depth) { |
195 // 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 |
196 // reallocating. | 196 // reallocating. |
197 json_string_->append(std::string(depth * 3, ' ')); | 197 json_string_->append(std::string(depth * 3, ' ')); |
198 } | 198 } |
199 | 199 |
200 } // namespace base | 200 } // namespace base |
OLD | NEW |