| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/common/json_value_serializer.h" | 5 #include "chrome/common/json_value_serializer.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/json_reader.h" | 8 #include "base/json_reader.h" |
| 9 #include "base/json_writer.h" | 9 #include "base/json_writer.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "chrome/common/logging_chrome.h" | |
| 12 | 11 |
| 13 JSONStringValueSerializer::~JSONStringValueSerializer() {} | 12 JSONStringValueSerializer::~JSONStringValueSerializer() {} |
| 14 | 13 |
| 15 bool JSONStringValueSerializer::Serialize(const Value& root) { | 14 bool JSONStringValueSerializer::Serialize(const Value& root) { |
| 16 if (!json_string_ || initialized_with_const_string_) | 15 if (!json_string_ || initialized_with_const_string_) |
| 17 return false; | 16 return false; |
| 18 | 17 |
| 19 JSONWriter::Write(&root, pretty_print_, json_string_); | 18 JSONWriter::Write(&root, pretty_print_, json_string_); |
| 20 | 19 |
| 21 return true; | 20 return true; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 49 } | 48 } |
| 50 | 49 |
| 51 Value* JSONFileValueSerializer::Deserialize(std::string* error_message) { | 50 Value* JSONFileValueSerializer::Deserialize(std::string* error_message) { |
| 52 std::string json_string; | 51 std::string json_string; |
| 53 if (!file_util::ReadFileToString(json_file_path_, &json_string)) { | 52 if (!file_util::ReadFileToString(json_file_path_, &json_string)) { |
| 54 return NULL; | 53 return NULL; |
| 55 } | 54 } |
| 56 JSONStringValueSerializer serializer(json_string); | 55 JSONStringValueSerializer serializer(json_string); |
| 57 return serializer.Deserialize(error_message); | 56 return serializer.Deserialize(error_message); |
| 58 } | 57 } |
| OLD | NEW |