| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 (const auto& value : *list) { | 130 for (const auto& value : *list) { |
| 131 if (omit_binary_values_ && value.GetType() == Value::Type::BINARY) | 131 if (omit_binary_values_ && value->GetType() == Value::Type::BINARY) |
| 132 continue; | 132 continue; |
| 133 | 133 |
| 134 if (first_value_has_been_output) { | 134 if (first_value_has_been_output) { |
| 135 json_string_->push_back(','); | 135 json_string_->push_back(','); |
| 136 if (pretty_print_) | 136 if (pretty_print_) |
| 137 json_string_->push_back(' '); | 137 json_string_->push_back(' '); |
| 138 } | 138 } |
| 139 | 139 |
| 140 if (!BuildJSONString(value, depth)) | 140 if (!BuildJSONString(*value, depth)) |
| 141 result = false; | 141 result = false; |
| 142 | 142 |
| 143 first_value_has_been_output = true; | 143 first_value_has_been_output = true; |
| 144 } | 144 } |
| 145 | 145 |
| 146 if (pretty_print_) | 146 if (pretty_print_) |
| 147 json_string_->push_back(' '); | 147 json_string_->push_back(' '); |
| 148 json_string_->push_back(']'); | 148 json_string_->push_back(']'); |
| 149 return result; | 149 return result; |
| 150 } | 150 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 201 } |
| 202 NOTREACHED(); | 202 NOTREACHED(); |
| 203 return false; | 203 return false; |
| 204 } | 204 } |
| 205 | 205 |
| 206 void JSONWriter::IndentLine(size_t depth) { | 206 void JSONWriter::IndentLine(size_t depth) { |
| 207 json_string_->append(depth * 3U, ' '); | 207 json_string_->append(depth * 3U, ' '); |
| 208 } | 208 } |
| 209 | 209 |
| 210 } // namespace base | 210 } // namespace base |
| OLD | NEW |