| 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" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 case Value::TYPE_LIST: | 134 case Value::TYPE_LIST: |
| 135 { | 135 { |
| 136 json_string_->append("["); | 136 json_string_->append("["); |
| 137 if (pretty_print_) | 137 if (pretty_print_) |
| 138 json_string_->append(" "); | 138 json_string_->append(" "); |
| 139 | 139 |
| 140 const ListValue* list = static_cast<const ListValue*>(node); | 140 const ListValue* list = static_cast<const ListValue*>(node); |
| 141 for (size_t i = 0; i < list->GetSize(); ++i) { | 141 for (size_t i = 0; i < list->GetSize(); ++i) { |
| 142 Value* value = NULL; | 142 const Value* value = NULL; |
| 143 bool result = list->Get(i, &value); | 143 bool result = list->Get(i, &value); |
| 144 DCHECK(result); | 144 DCHECK(result); |
| 145 | 145 |
| 146 if (omit_binary_values_ && value->GetType() == Value::TYPE_BINARY) { | 146 if (omit_binary_values_ && value->GetType() == Value::TYPE_BINARY) { |
| 147 continue; | 147 continue; |
| 148 } | 148 } |
| 149 | 149 |
| 150 if (i != 0) { | 150 if (i != 0) { |
| 151 json_string_->append(","); | 151 json_string_->append(","); |
| 152 if (pretty_print_) | 152 if (pretty_print_) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 JsonDoubleQuote(UTF8ToUTF16(str), true, json_string_); | 227 JsonDoubleQuote(UTF8ToUTF16(str), true, json_string_); |
| 228 } | 228 } |
| 229 | 229 |
| 230 void JSONWriter::IndentLine(int depth) { | 230 void JSONWriter::IndentLine(int depth) { |
| 231 // It may be faster to keep an indent string so we don't have to keep | 231 // It may be faster to keep an indent string so we don't have to keep |
| 232 // reallocating. | 232 // reallocating. |
| 233 json_string_->append(std::string(depth * 3, ' ')); | 233 json_string_->append(std::string(depth * 3, ' ')); |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace base | 236 } // namespace base |
| OLD | NEW |