| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 case Value::TYPE_LIST: { | 121 case Value::TYPE_LIST: { |
| 122 json_string_->push_back('['); | 122 json_string_->push_back('['); |
| 123 if (pretty_print_) | 123 if (pretty_print_) |
| 124 json_string_->push_back(' '); | 124 json_string_->push_back(' '); |
| 125 | 125 |
| 126 const ListValue* list = NULL; | 126 const ListValue* list = NULL; |
| 127 bool first_value_has_been_output = false; | 127 bool first_value_has_been_output = false; |
| 128 bool result = node.GetAsList(&list); | 128 bool result = node.GetAsList(&list); |
| 129 DCHECK(result); | 129 DCHECK(result); |
| 130 for (ListValue::const_iterator it = list->begin(); it != list->end(); | 130 for (const auto& value : *list) { |
| 131 ++it) { | |
| 132 const Value* value = *it; | |
| 133 if (omit_binary_values_ && value->GetType() == Value::TYPE_BINARY) | 131 if (omit_binary_values_ && value->GetType() == Value::TYPE_BINARY) |
| 134 continue; | 132 continue; |
| 135 | 133 |
| 136 if (first_value_has_been_output) { | 134 if (first_value_has_been_output) { |
| 137 json_string_->push_back(','); | 135 json_string_->push_back(','); |
| 138 if (pretty_print_) | 136 if (pretty_print_) |
| 139 json_string_->push_back(' '); | 137 json_string_->push_back(' '); |
| 140 } | 138 } |
| 141 | 139 |
| 142 if (!BuildJSONString(*value, depth)) | 140 if (!BuildJSONString(*value, depth)) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 201 } |
| 204 NOTREACHED(); | 202 NOTREACHED(); |
| 205 return false; | 203 return false; |
| 206 } | 204 } |
| 207 | 205 |
| 208 void JSONWriter::IndentLine(size_t depth) { | 206 void JSONWriter::IndentLine(size_t depth) { |
| 209 json_string_->append(depth * 3U, ' '); | 207 json_string_->append(depth * 3U, ' '); |
| 210 } | 208 } |
| 211 | 209 |
| 212 } // namespace base | 210 } // namespace base |
| OLD | NEW |