zoukankan      html  css  js  c++  java
  • C++ 项目中直接使用JsonCpp源码文件

    之前在网上看到使用JsonCpp都是以库的形式使用(编译源码为静态库或者动态库),这样引用很方便,但有时候报错调试看不到错误的地方,所以就想直接把源文件添加到项目中,方便调试

    这是用到源码文件:

    创建控制台工程把对应的文件导入到工程中:

    main.cpp使用jsoncpp

    #include "stdafx.h"
    #include "jsonjson.h"
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    
        Json::Value root;
        Json::Value arrayObj;
        Json::Value item;
    
    
        item["uid"]=Json::Value("chechenluoyang@163.com");
        item["fileName"]=Json::Value("梅西.txt");
        item["time"]=Json::Value("2017.07.28 10:55:22");
        item["type"]=Json::Value("Libcurl HTTP POST JSON");
        item["authList"]=Json::Value("test");
        arrayObj.append(item);
    
    
        root  = arrayObj;
        std::string jsonout = root.toStyledString();
    
        return 0;
    }

    编译报错:

    这是因为工程默认属性是要预编译头文件,解决的办法是关掉

    2.两种格式化json串

    Demo

  • 相关阅读:
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    重读《深入理解Java虚拟机》三、Java虚拟机执行的数据入口(类文件结构)
  • 原文地址:https://www.cnblogs.com/chechen/p/7251128.html
Copyright © 2011-2022 走看看