0
点赞
收藏
分享

微信扫一扫

C++笔记:实现一个字符串类(构造函数、拷贝构造函数、拷贝赋值函数)

君之言之 2024-06-29 阅读 33

下载

jsoncpp下载位置:

GitHub - open-source-parsers/jsoncpp: A C++ library for interacting with JSON.

编译库

生成的库文件位置如下

管理库和头文件

配置visual studio

使用jsoncpp

#include <iostream>
#include <json/json.h>
#include <json/value.h>
#include <json/reader.h>

int main()
{
    //std::cout << "Hello World!\n";
    Json::Value root;
    root["id"] = 1001;
    root["data"] = "hello world";
    std::string request = root.toStyledString();
    std::cout << "request is " << request << std::endl;
    Json::Value root2;
    Json::Reader reader;
    reader.parse(request, root2);
    std::cout << "msg id is " << root2["id"] << " msg is " << root2["data"] << std::endl;
}

运行效果如下:

举报

相关推荐

0 条评论