Jsoncpp使用
常用組件
Value: 支持的類型,null,int,uint,double,string(utf-8),bool,array,object
Writer:
簡介: 將json::value轉化為字符串.
使用: Writer 類是一個純虛類,并不能直接使用。在此我們使用Json::Writer的子類:Json::FastWriter、Json::StyledWriter、Json::StyledStreamWriter.
-差別:fast是連續的,style是格式好看的,不必要.
eg:
Json::FastWriter fast_writer;std::cout << fast_writer.write(root) << std::endl;Reader:
簡介: 將字符串轉為Json::value.
eg:
Json::Reader reader; Json::Value json_object; const char* json_document = "{/"age/" : 26,/"name/" : /"huchao/"}"; if (!reader.parse(json_document, json_object))return 0;std::cout << json_object["name"] << std::endl; std::cout << json_object["age"] << std::endl;常用成員:
as系列函數: asString,asInt,將Json::value轉化為相應類型.?
is系列函數: 判斷
參考:http://blog.csdn.net/wangchangshuai0010/article/details/18180223
轉載于:https://www.cnblogs.com/willaty/p/8022583.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
- 上一篇: sourceInsight4 破解笔记(
- 下一篇: 5天玩转C#并行和多线程编程 —— 第四