diff options
-rw-r--r-- | common/binder_utils.cc | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/common/binder_utils.cc b/common/binder_utils.cc index 641019a..44f1c59 100644 --- a/common/binder_utils.cc +++ b/common/binder_utils.cc @@ -48,17 +48,14 @@ android::binder::Status ParseDictionary( std::unique_ptr<base::DictionaryValue>* dict) { int error = 0; std::string message; - std::unique_ptr<base::Value> value{ + auto value = base::JSONReader::ReadAndReturnError(ToString(json), base::JSON_PARSE_RFC, - &error, &message) - .release()}; - base::DictionaryValue* dict_value = nullptr; - if (!value || !value->GetAsDictionary(&dict_value)) { + &error, &message); + *dict = base::DictionaryValue::From(std::move(value)); + if (!*dict) { return android::binder::Status::fromServiceSpecificError( error, android::String8{message.c_str()}); } - dict->reset(dict_value); - value.release(); // |dict| now owns the object. return android::binder::Status::ok(); } |