Beispiel #1
0
bool Global::deserialize(JSONValue &j_json_val)
{
	JSONObject j_json_obj = j_json_val.asObject();

	_encoders = deserializeCfgMap(j_json_obj["encoders"]);
	_channels = deserializeCfgMap(j_json_obj["channels"]);

	JSONObject j_obj_config = j_json_obj["config"]->asObject();
	for(JSONObject::iterator it = j_obj_config.begin(); it != j_obj_config.end(); ++it)
	{
		_config[it->first] = it->second->getString();
	}
	return true;
}
Beispiel #2
0
TEST(JSON, read) {

	JSONReader reader;
	JSONValue val = reader.parse("{\"a\": 1337, \"b\": false, \"c\":null, \"d\":[1,2,3], \"e\":{\"abc\":\"xyz\"} }");
	JSONObject* obj = val.asObject();

	ASSERT_EQ(1337, obj->getInt("a"));
	ASSERT_EQ(false, obj->getBoolean("b"));
	ASSERT_TRUE(obj->containsValue("c"));
	ASSERT_EQ(1, obj->getArray("d")->get(0).asInt());
	ASSERT_EQ(2, obj->getArray("d")->get(1).asInt());
	ASSERT_EQ(3, obj->getArray("d")->get(2).asInt());
	ASSERT_EQ("xyz", obj->getObject("e")->getString("abc"));
}