This source file includes following definitions.
- ReadJson
#include "tools/json_schema_compiler/test/test_util.h"
#include <string>
#include "base/json/json_reader.h"
#include "base/logging.h"
namespace json_schema_compiler {
namespace test_util {
scoped_ptr<base::Value> ReadJson(const base::StringPiece& json) {
int error_code;
std::string error_msg;
scoped_ptr<base::Value> result(base::JSONReader::ReadAndReturnError(
json,
base::JSON_ALLOW_TRAILING_COMMAS,
&error_code,
&error_msg));
CHECK(result) << error_msg;
return result.Pass();
}
scoped_ptr<base::ListValue> List(base::Value* a) {
scoped_ptr<base::ListValue> list(new base::ListValue());
list->Append(a);
return list.Pass();
}
scoped_ptr<base::ListValue> List(base::Value* a, base::Value* b) {
scoped_ptr<base::ListValue> list = List(a);
list->Append(b);
return list.Pass();
}
scoped_ptr<base::ListValue> List(base::Value* a,
base::Value* b,
base::Value* c) {
scoped_ptr<base::ListValue> list = List(a, b);
list->Append(c);
return list.Pass();
}
scoped_ptr<base::DictionaryValue> Dictionary(
const std::string& ak, base::Value* av) {
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetWithoutPathExpansion(ak, av);
return dict.Pass();
}
scoped_ptr<base::DictionaryValue> Dictionary(
const std::string& ak, base::Value* av,
const std::string& bk, base::Value* bv) {
scoped_ptr<base::DictionaryValue> dict = Dictionary(ak, av);
dict->SetWithoutPathExpansion(bk, bv);
return dict.Pass();
}
scoped_ptr<base::DictionaryValue> Dictionary(
const std::string& ak, base::Value* av,
const std::string& bk, base::Value* bv,
const std::string& ck, base::Value* cv) {
scoped_ptr<base::DictionaryValue> dict = Dictionary(ak, av, bk, bv);
dict->SetWithoutPathExpansion(ck, cv);
return dict.Pass();
}
}
}