本文整理汇总了C++中StringBuilder::appendQuotedJSONString方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuilder::appendQuotedJSONString方法的具体用法?C++ StringBuilder::appendQuotedJSONString怎么用?C++ StringBuilder::appendQuotedJSONString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuilder
的用法示例。
在下文中一共展示了StringBuilder::appendQuotedJSONString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: asJSON
void Entry::asJSON(StringBuilder& json, const Storage::RecordInfo& info) const
{
json.appendLiteral("{\n");
json.appendLiteral("\"hash\": ");
json.appendQuotedJSONString(m_key.hashAsString());
json.appendLiteral(",\n");
json.appendLiteral("\"bodySize\": ");
json.appendNumber(info.bodySize);
json.appendLiteral(",\n");
json.appendLiteral("\"worth\": ");
json.appendNumber(info.worth);
json.appendLiteral(",\n");
json.appendLiteral("\"partition\": ");
json.appendQuotedJSONString(m_key.partition());
json.appendLiteral(",\n");
json.appendLiteral("\"timestamp\": ");
json.appendNumber(std::chrono::duration_cast<std::chrono::milliseconds>(m_timeStamp.time_since_epoch()).count());
json.appendLiteral(",\n");
json.appendLiteral("\"URL\": ");
json.appendQuotedJSONString(m_response.url().string());
json.appendLiteral(",\n");
json.appendLiteral("\"bodyHash\": ");
json.appendQuotedJSONString(info.bodyHash);
json.appendLiteral(",\n");
json.appendLiteral("\"bodyShareCount\": ");
json.appendNumber(info.bodyShareCount);
json.appendLiteral(",\n");
json.appendLiteral("\"headers\": {\n");
bool firstHeader = true;
for (auto& header : m_response.httpHeaderFields()) {
if (!firstHeader)
json.appendLiteral(",\n");
firstHeader = false;
json.appendLiteral(" ");
json.appendQuotedJSONString(header.key);
json.appendLiteral(": ");
json.appendQuotedJSONString(header.value);
}
json.appendLiteral("\n}\n");
json.appendLiteral("}");
}
示例2: json
//.........这里部分代码省略.........
break;
}
};
json.append('{');
// version
json.appendLiteral("\"version\":1");
// nodes
json.append(',');
json.appendLiteral("\"nodes\":");
json.append('[');
json.appendLiteral("0,0,0,0"); // <root>
for (HeapSnapshot* snapshot = m_profiler.mostRecentSnapshot(); snapshot; snapshot = snapshot->previous()) {
for (auto& node : snapshot->m_nodes)
appendNodeJSON(node);
}
json.append(']');
// node class names
json.append(',');
json.appendLiteral("\"nodeClassNames\":");
json.append('[');
Vector<const char *> orderedClassNames(classNameIndexes.size());
for (auto& entry : classNameIndexes)
orderedClassNames[entry.value] = entry.key;
classNameIndexes.clear();
bool firstClassName = true;
for (auto& className : orderedClassNames) {
if (!firstClassName)
json.append(',');
firstClassName = false;
json.appendQuotedJSONString(className);
}
orderedClassNames.clear();
json.append(']');
// Process edges.
// Replace pointers with identifiers.
// Remove any edges that we won't need.
m_edges.removeAllMatching([&] (HeapSnapshotEdge& edge) {
// If the from cell is null, this means a <root> edge.
if (!edge.from.cell)
edge.from.identifier = 0;
else {
auto fromLookup = allowedNodeIdentifiers.find(edge.from.cell);
if (fromLookup == allowedNodeIdentifiers.end())
return true;
edge.from.identifier = fromLookup->value;
}
if (!edge.to.cell)
edge.to.identifier = 0;
else {
auto toLookup = allowedNodeIdentifiers.find(edge.to.cell);
if (toLookup == allowedNodeIdentifiers.end())
return true;
edge.to.identifier = toLookup->value;
}
return false;
});
allowedNodeIdentifiers.clear();
m_edges.shrinkToFit();
示例3: json
//.........这里部分代码省略.........
json.append(',');
json.appendNumber(edge.to.identifier);
json.append(',');
json.appendNumber(edgeTypeToNumber(edge.type));
json.append(',');
switch (edge.type) {
case EdgeType::Property:
case EdgeType::Variable: {
auto result = edgeNameIndexes.add(edge.u.name, nextEdgeNameIndex);
if (result.isNewEntry)
nextEdgeNameIndex++;
unsigned edgeNameIndex = result.iterator->value;
json.appendNumber(edgeNameIndex);
break;
}
case EdgeType::Index:
json.appendNumber(edge.u.index);
break;
default:
// No data for this edge type.
json.append('0');
break;
}
};
json.append('{');
// version
json.appendLiteral("\"version\":2");
// type
json.append(',');
json.appendLiteral("\"type\":");
json.appendQuotedJSONString(snapshotTypeToString(m_snapshotType));
// nodes
json.append(',');
json.appendLiteral("\"nodes\":");
json.append('[');
// <root>
if (m_snapshotType == SnapshotType::GCDebuggingSnapshot)
json.appendLiteral("0,0,0,0,0,\"0x0\",\"0x0\"");
else
json.appendLiteral("0,0,0,0");
for (HeapSnapshot* snapshot = m_profiler.mostRecentSnapshot(); snapshot; snapshot = snapshot->previous()) {
for (auto& node : snapshot->m_nodes)
appendNodeJSON(node);
}
json.append(']');
// node class names
json.append(',');
json.appendLiteral("\"nodeClassNames\":");
json.append('[');
Vector<String> orderedClassNames(classNameIndexes.size());
for (auto& entry : classNameIndexes)
orderedClassNames[entry.value] = entry.key;
classNameIndexes.clear();
bool firstClassName = true;
for (auto& className : orderedClassNames) {
if (!firstClassName)
json.append(',');
firstClassName = false;
json.appendQuotedJSONString(className);
}