本文整理汇总了C++中JSONNode::write_formatted方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONNode::write_formatted方法的具体用法?C++ JSONNode::write_formatted怎么用?C++ JSONNode::write_formatted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONNode
的用法示例。
在下文中一共展示了JSONNode::write_formatted方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_formatted
void write_formatted(JSONNode n, const char *filename){
if(n.type()!=JSON_NULL){
std::string jc = n.write_formatted();
std::ofstream out(filename);
out << jc;
out.close();
}
}
示例2: getAllCurrenciesInJsonFormat
ptree currencyHandler::getAllCurrenciesInJsonFormat() {
JSONNode n(JSON_NODE);
n.push_back(JSONNode("String Node", "String Value"));
n.push_back(JSONNode("Integer Node", 42));
n.push_back(JSONNode("Floating Point Node", 3.14));
n.push_back(JSONNode("Boolean Node", true));
std::string jc = n.write_formatted();
std::cout << jc << std::endl;
JSONNode n(JSON_NODE);
n.push_back(JSONNode("RootA", "Hello World"));
JSONNode c(JSON_ARRAY);
c.set_name("ArrayOfNumbers");
c.push_back(JSONNode("", 16));
c.push_back(JSONNode("", 42));
c.push_back(JSONNode("", 128));
n.push_back(c);
std::string jc = n.write_formatted();
std::cout << jc << std::endl;
std::string json = "{\"RootA\":\"Value in parent node\",\"ChildNode\":{\"ChildA\":\"String Value\",\"ChildB\":42}}";
JSONNode n = libjson::parse(json);
ParseJSON(n);
JSONNode n(JSON_NODE);
n.push_back(JSONNode("RootA", "Value in parent node"));
JSONNode c(JSON_NODE);
c.set_name("ChildNode");
c.push_back(JSONNode("ChildA", "String Value"));
c.push_back(JSONNode("ChildB", 42));
n.push_back(c);
std::string jc = n.write_formatted();
std::cout << jc << std::endl;
return allCurrenciesJsonArray;
}