1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/json/json_value_converter.h"
7 #include "base/strings/utf_string_conversions.h"
12 bool BasicValueConverter<int>::Convert(
13 const base::Value& value, int* field) const {
17 *field = value.GetInt();
21 bool BasicValueConverter<std::string>::Convert(
22 const base::Value& value, std::string* field) const {
23 if (!value.is_string())
26 *field = value.GetString();
30 bool BasicValueConverter<std::u16string>::Convert(const base::Value& value,
31 std::u16string* field) const {
32 if (!value.is_string())
35 *field = base::UTF8ToUTF16(value.GetString());
39 bool BasicValueConverter<double>::Convert(
40 const base::Value& value, double* field) const {
41 if (!value.is_double() && !value.is_int())
44 *field = value.GetDouble();
48 bool BasicValueConverter<bool>::Convert(
49 const base::Value& value, bool* field) const {
53 *field = value.GetBool();
57 } // namespace internal