本文整理汇总了C++中JSONNode::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONNode::GetType方法的具体用法?C++ JSONNode::GetType怎么用?C++ JSONNode::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONNode
的用法示例。
在下文中一共展示了JSONNode::GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// ****************************************************************************
// Method: SharedDaemon::handleConnection
//
// Purpose:
// Handle the incomming connection..
//
// Arguments:
//
// Returns:
//
// Note:
//
// Programmer: Hari Krishnan
// Creation: Oct 13, 2012
//
// Modifications:
// Kathleen Biagas, Mon Dec 3 12:01:15 PST 2012
// Use operator[] instead of 'at' to support older MSVC compiler.
//
// ****************************************************************************
bool
SharedDaemon::ParseInput(const QString& input, JSONNode& output)
{
if(input.startsWith("{"))
{
JSONNode node;
node.Parse(input.toStdString());
//std::cout << node.ToString() << std::endl;
/// also check to make sure password is coorect..
if(node.GetType() != JSONNode::JSONOBJECT ||
!node.HasKey("password") ||
node.GetJsonObject()["password"].GetString() != password.toStdString())
return false;
output = node;
return true;
}
return false;
}
示例2: if
bool
ProgrammableOpAttributes::SetupPipeline(const JSONNode& atts, stringVector& args, const std::string& parent)
{
if(atts.GetType() != JSONNode::JSONARRAY)
return false;
const JSONNode::JSONArray& array = atts.GetArray();
for(int i = 0; i < array.size(); ++i)
{
/// need key, value pair
/// this can be in the form of a dictionary, "a = b", pair tuple (a,b), or a pair array [a,b]
JSONNode node = array[i];
JSONNode key,value;
if(node.GetType() == JSONNode::JSONARRAY)
{
if(node.GetArray().size() != 2) continue;
key = node.GetArray()[0];
value = node.GetArray()[1];
}
else if(node.GetType() == JSONNode::JSONOBJECT)
{
/// parse through dictionary and compute arguments from names..
const JSONNode::JSONObject& obj = node.GetJsonObject();
if(obj.size() != 1) continue;
const JSONNode::JSONObject::const_iterator itr = obj.begin();
key = itr->first;
value = itr->second;
}
else if(node.GetType() == JSONNode::JSONSTRING)
{
std::string pair = node.GetString();
int index = pair.find("=");
if(index == std::string::npos) continue;
key = pair.substr(0,index);
value = trim(pair.substr(index+1));
}
if(key.GetType() != JSONNode::JSONSTRING) continue;
std::string keystr = trim(key.GetString());
std::ostringstream str;
str << "import json\n";
if(value.GetType() == JSONNode::JSONSTRING)
{
std::string v = trim(value.GetString());
///character at 0 and has :
if(v.find(":") != std::string::npos && v.find(":") == 0)
{
/// optionally handle whether it can be as_vtkarray, as_ndarray, or as_rarray
size_t index = v.find(":as_ndarray");
if(index == std::string::npos)
index = v.find(":as_rarray");
if(index != std::string::npos)
{
std::string newName = getNextName();
v = v.substr(0,index);
AddNode(newName, "as_ndarray");
AddConnection(v, newName, "in");
AddConnection(newName,parent,keystr);
}
else
{
index = v.find(":as_vtkarray");
if(index != std::string::npos)
v = v.substr(0,index);
AddConnection(v,parent,keystr);
}
}
else
{
std::string escapedCode = trim(value.GetString());
replace(escapedCode,"\n","\\\n");
replace(escapedCode,"'","\"");
escapedCode = "'" + escapedCode + "'";
str << "try:\n"
<< " a = json.loads(" << escapedCode << ")\n"
<< "except:\n"
<< " a = " << escapedCode << "\n"
<< "setout(a)\n";
AddPythonScript(keystr,stringVector(),str.str());
AddNode(keystr,keystr);
AddConnection(keystr,parent,keystr);
}
}
else
{
str << "setout(json.loads('" << trim(value.ToString()) << "'))\n";
AddPythonScript(keystr,stringVector(),str.str());
//.........这里部分代码省略.........