Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: third_party/libaddressinput/chromium/util/json.cc

Issue 68323005: Build libaddressinput in Chrome for requestAutocomplete(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "util/json.h"
6
7 #include "base/json/json_reader.h"
8 #include "base/logging.h"
9
10 namespace i18n {
11 namespace addressinput {
12
13 Json::Json() {}
14 Json::~Json() {}
15
16 bool Json::ParseObject(const std::string& json) {
17 dict_.reset();
18
19 // |json| is converted to a |c_str()| here because rapidjson and other parts
20 // of the standalone library use char* rather than std::string.
21 scoped_ptr<base::Value> parsed(base::JSONReader::Read(json.c_str()));
22 if (parsed && parsed->IsType(base::Value::TYPE_DICTIONARY))
23 dict_.reset(static_cast<base::DictionaryValue*>(parsed.release()));
24
25 return !!dict_;
26 }
27
28 bool Json::HasStringValueForKey(const std::string& key) const {
29 base::Value* val = NULL;
30 dict_->GetWithoutPathExpansion(key, &val);
31 return val && val->IsType(base::Value::TYPE_STRING);
32 }
33
34 std::string Json::GetStringValueForKey(const std::string& key) const {
35 std::string result;
36 dict_->GetStringWithoutPathExpansion(key, &result);
37 return result;
38 }
39
40 } // namespace addressinput
41 } // namespace i18n
OLDNEW
« no previous file with comments | « third_party/libaddressinput/chromium/util/json.h ('k') | third_party/libaddressinput/libaddressinput.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698