JsonCpp lib使用

jsonCpp做的很强大,这里,我自己进行了编译,修改成了lib方式

这里我的编程环境 VC 6


#include "stdafx.h"
#pragma warning(disable : 4786) 
#include    
#include    
#include "json/json.h" 
#pragma comment(lib,"jsonlibmtd.lib")
#define SIZE 10; 

using namespace std; 

// int main(int argc, char* argv[])   
// {   
// 	
//     Json::Value root; 
//     Json::FastWriter fast_writer; 
// 	
//     Json::Value Person; 
// 	
//     Person["name"] = "Tsiannian"; 
//     Person["age"] = "23"; 
//     root.append(Person); 
// 	
//     Person["name"] = "zSai"; 
//     Person["age"] = "21"; 
//     root.append(Person); 
// 	
//     std::cout << fast_writer.write(root) << endl; 
//     getchar();   
//     return 0;   
// }


int main(int argc, char* argv[])   
{   
    fstream file("test.json");   
    if (!file)   
    {   
        cout<<"Open file test.json fail!!!"<
上面的代码是使用别人的,自己修改了一下

内容

"test.json"

[{"errcode":0,"bookname":"dasemimi","data":"ffff","downcount":"1","rmb":"1","id":"6"},
{"errcode":0,"bookname":"xaiosemimi","data":"fffffffffffff","downcount":"0","rmb":"0","id":"7"},
{"errcode":0,"bookname":"dasfsfdsadfsd","data":"ssss","downcount":"0","rmb":"0","id":"12"}]


测试代码及lib下载

http://download.csdn.net/detail/u012607841/6903835


你可能感兴趣的:(C/C++)