本文整理汇总了C++中json::Value::getString方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::getString方法的具体用法?C++ Value::getString怎么用?C++ Value::getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::Value
的用法示例。
在下文中一共展示了Value::getString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompareJson
void CompareJson(json::Value& lhs, json::Value& rhs, json::Value& output) {
std::string lstr, rstr;
if (rhs.type() != lhs.type()) return;
switch (lhs.type()) {
case json::Value::tString:
lstr = lhs.getString();
rstr = rhs.getString();
if (!lstr.empty() && lstr[0] == '$' && lstr.back() == '$') {
size_t slash = lstr.find('/');
std::string cat = lstr.substr(1, slash - 1);
std::string name = lstr.substr(slash + 1, lstr.length() - slash - 2);
output[cat][name] = rstr;
}
break;
case json::Value::tArray:
for (size_t i = 0; i < lhs.length(); ++i) {
if (i < rhs.length()) {
CompareJson(lhs[i], rhs[i], output);
}
}
break;
case json::Value::tObject:
for (auto it = lhs.begin(); it != lhs.end(); ++it) {
if (rhs.has(it.key())) {
CompareJson(*it, rhs[it.key()], output);
}
}
break;
}
}
示例2: read
void Session::read(const JSON::Value &value) {
creationTime =
value.has("created") ?
(uint64_t)Time::parse(value.getString("created")) : 0;
lastUsed =
value.has("last_used") ?
(uint64_t)Time::parse(value.getString("last_used")) : 0;
user = value.getString("user", "");
ip = value.has("ip") ? IPAddress(value.getString("ip")) : IPAddress();
}
示例3: numberToWide
static void numberToWide(PrintTextA &print) {
JSON::PFactory f = JSON::create();
JSON::Value v = f->newValue((natural)123);
String tst1 = v->getString();
String tst2 = v->getString();
print("%1,%2") << tst1 << tst2;
}
示例4: TransformJson
void TransformJson(json::Value& value, json::Value& data, Func const& func) {
switch (value.type()) {
case json::Value::tString:
value = func(value.getString(), data);
break;
case json::Value::tArray:
case json::Value::tObject:
for (auto& sub : value) {
TransformJson(sub, data, func);
}
break;
}
}
示例5: loadJSON
void Atom::loadJSON(const JSON::Value &value, float scale) {
if (0 < value.size()) type = value.getString(0);
else THROWS("Atom expected list of at least length 1");
if (String::toUpper(type) == "UNKNOWN") type = "?";
if (1 < value.size()) charge = (float)value.getNumber(1);
if (2 < value.size()) radius = (float)value.getNumber(2) * scale;
if (3 < value.size()) mass = (float)value.getNumber(3);
if (4 < value.size()) number = (unsigned)value.getNumber(4);
else number = numberFromName(type);
if (!number) number = numberFromName(type);
if (!charge) charge = chargeFromNumber(number);
if (!radius) radius = radiusFromNumber(number);
if (!mass) mass = massFromNumber(number);
}