Ignore invalid JSON object when converting NSDictionary

This commit is contained in:
Cheng Zhao 2016-05-18 14:50:12 +09:00
parent 97250b53e8
commit 240c346d02

View file

@ -26,7 +26,7 @@ NSDictionary* DictionaryValueToNSDictionary(const base::DictionaryValue& value)
scoped_ptr<base::DictionaryValue> NSDictionaryToDictionaryValue(
NSDictionary* dict) {
if (!dict)
if (!dict || ![NSJSONSerialization isValidJSONObject:dict])
return nullptr;
NSData* data = [NSJSONSerialization dataWithJSONObject:dict