jsoncpp vc2005 编译测试
来源:互联网 发布:毛孔抚子 知乎 编辑:程序博客网 时间:2024/05/18 03:55
新建一个vc8 win32 控制台程序
使用多字节字符
包含jsoncpp_src_0_5_0/src/lib_json 下的所有代码到工程中
引用jsoncpp_src_0_5_0/include/json/json.h
编写如下代码:
// test_jsoncpp_vc8.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include "../../include/json/json.h"
int _tmain(int argc, _TCHAR* argv[])
{
std::string doc;
doc = "{ /"encoding/" : /"UTF-8/" }";
Json::Value root; // will contains the root value after parsing.
Json::Reader reader;
bool parsingSuccessful = reader.parse( doc, root );
if ( !parsingSuccessful )
{
// report to the user the failure and their locations in the document.
std::cout << "Failed to parse configuration/n"
<< reader.getFormatedErrorMessages();
return 0;
}
// Get the value of the member of root named 'encoding', return 'UTF-8' if there is no
// such member.
std::string encoding;
encoding = root.get("encoding", "UTF-8" ).asString();
// Get the value of the member of root named 'encoding', return a 'null' value if
// there is no such member.
/*
const Json::Value plugins = root["plug-ins"];
for ( int index = 0; index < plugins.size(); ++index ) // Iterates over the sequence elements.
loadPlugIn( plugins[index].asString() );
setIndentLength( root["indent"].get("length", 3).asInt() );
setIndentUseSpace( root["indent"].get("use_space", true).asBool() );
*/
// ...
// At application shutdown to make the new configuration document:
// Since Json::Value has implicit constructor for all value types, it is not
// necessary to explicitly construct the Json::Value object:
root["encoding"] = "GB2312";
root["indent"]["length"] = 2;
root["indent"]["use_space"] = 5;
Json::StyledWriter writer;
// Make a new JSON document for the configuration. Preserve original comments.
std::string outputConfig = writer.write( root );
// You can also use streams. This will put the contents of any JSON
// stream at a particular sub-value, if you'd like.
//std::cin >> root["subtree"];
root["subtree"] = "日";
// And you can write to a stream, using the StyledWriter automatically.
std::cout << root;
getchar();
return 0;
}
运行结果:
{
"encoding" : "GB2312",
"indent" :
{
"length" : 2,
"use_space" : 5
},
"subtree" : "日"
}
- jsoncpp vc2005 编译测试
- JSONCpp编译
- VC2005 + SQLite 3.6.3 编译、测试开发手记
- VC2005 + SQLite 3.6.3 编译、测试开发手记
- VC2005 +SQLite 3.6.3 编译、测试开发手记
- linux下jsoncpp的编译和测试使用
- linux下jsoncpp的编译和测试使用
- VC2005 编译 X264 问题
- VC2005编译的问题
- VC2005编译ACE+SSL
- vc2005 编译 Delta3d
- VC2005编译log4cpp1.0
- vc2005编译使用stlport
- VC2005编译安装QT
- linux 下编译jsoncpp
- jsoncpp在linux编译
- Linux下编译Jsoncpp
- Linux下编译Jsoncpp
- 工作中
- Android UI开发专题(二) 之绘图基础
- Ogre Mesh的加载
- Symbian OS 源码获得方式(本站原创)
- 一步一步学List Control控件的用法(第三步)----设置风格
- jsoncpp vc2005 编译测试
- Windows 7修改用户登录方式
- jQuery插件---获取URL参数.
- 依赖、关联、聚合、组合还有泛化的关系
- EhCache的使用详解
- C# winform与 flash as 的交互通讯
- 强内聚、松耦合
- IT蚁族:蜗居和逃离
- VS2005集成SVN(AnkhSVN)