当前位置: 首页 > news >正文

专业html5网站建设2023年8月疫情严重吗

专业html5网站建设,2023年8月疫情严重吗,怎么做卖辅助网站,重庆推广渠道具体的步骤: 先下载rapidjson的依赖包 方式1:直接使用git去下载 地址:git clone https://github.com/miloyip/rapidjson.git 方式2:下载我上传的依赖包 将依赖包引入到项目中 1 将解压后的文件放在你c项目中 2 将rapidjson文…

具体的步骤:

  • 先下载rapidjson的依赖包

方式1:直接使用git去下载

地址:git clone https://github.com/miloyip/rapidjson.git

方式2:下载我上传的依赖包

  • 将依赖包引入到项目中

1  将解压后的文件放在你c++项目中

2 将rapidjson文件中的src目录引入到项目中

步骤:

1        打开项目,项目属性

 2 点击属性 -----》c++------》添加src目录--》确认退出

到这里你的项目就可以用rapidjson了

  • 开始使用rapidjson(有一些需要注意的地方)

创建头文件

#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/filereadstream.h"
#include "rapidjson/filewritestream.h"
#include "rapidjson/istreamwrapper.h"
#include "rapidjson/ostreamwrapper.h"
#include <iostream>
#include <fstream>
#include <stdio.h>


using namespace rapidjson;
using namespace std;


int rapidJsonTest();

创建cpp文件

#include "rapidJsonTest.h"
#include <vector>
#include "memory.h"
#include<ctime>
#include<stdio.h>

int rapidJsonTest()
{

 Document jsonDoc;
    Document::AllocatorType& allocator = jsonDoc.GetAllocator();
    jsonDoc.SetObject();

    //主对象
    Value value(kObjectType);
    value.AddMember("flag", 0, allocator);
    value.AddMember("msg", "操作成功", allocator);


    //result对象
    Value result(kObjectType);
    //添加result的基本信息
    result.AddMember("name", "(匿名)", allocator);
    result.AddMember("right_query", true, allocator);

    //创建一个array对象,用于存储t信息
    Value arraych(kArrayType);
    struct  chunnels
    {
        int chunnel;
        string username;
        string telphone;
    };

    
    for (int i = 0; i < 5; i++) {
        chunnels ch;
        ch.chunnel = 0;
        ch.username = "黎明";
        ch.telphone = "110";

        Value chu(kObjectType);
        Value v0;
        v0.SetInt(ch.chunnel);                //数值型这样写


        Value v1(ch.username.c_str(), allocator);   //字符串这样写就不会出现/u0000的问题了
        Value v2(ch.telphone.c_str(), allocator);

        chu.AddMember("chunnel", v0, allocator);
        chu.AddMember("username", v1, allocator);
        chu.AddMember("telphone", v2, allocator);

        chu.AddMember("第三种写法", "6666", allocator);   //直接内容的话,不需要转

        arraych.PushBack(chu, allocator);
    }
    
 

    //将集合添加到result对象中
    result.AddMember("chunnels", arraych, allocator);
    //将result对象加入到主对象
    value.AddMember("result", result, allocator);

    // 转为string
    StringBuffer str;
    Writer<StringBuffer> writer(str);
    value.Accept(writer);
    string strJson = str.GetString();
    cout << strJson << endl;

    return 0;
}

案例二

   int demo2(){

   cout << "json Value的新建及key的访问" << endl;

    Document jsonDoc;    //生成一个dom元素Document
    Document::AllocatorType& allocator = jsonDoc.GetAllocator(); //获取分配器
    jsonDoc.SetObject();    //将当前的Document设置为一个object,也就是说,整个Document是一个Object类型的dom元素

    // 新建Value对象1(object类型)
    Value value1(kObjectType);
    value1.AddMember("name", "语文", allocator);             // string型(给字段赋值,key必须为string型下同)
    value1.AddMember("score", 80, allocator);             // 整型
    value1.AddMember("right", true, allocator);           // 整型
    value1.AddMember("percent", 12.3456789123, allocator);// double型

    // 此时访问key是可以的
    if (value1.HasMember("name")) // 判断是否存在该key
    {
        if (value1["name"].IsString()) // 再判断类型是否正确
        {
            cout << "value1:name:" << value1["name"].GetString() << endl;
        }
        cout << "value1:score:" << value1["score"].GetInt() << endl; // 直接这样写有风险
    }

    // 新建Value对象(数组类型)
    Value value2(kArrayType);
    value2.PushBack(1, allocator);
    value2.PushBack(2, allocator);
    value2.PushBack(3, allocator);
    cout << "value:size()数组中元素个数:" << value2.Size() << endl;

    // 合并一个整体
    Value value3(kObjectType);
    value3.AddMember("name", "xiaoming", allocator);
    value3.AddMember("age", 18, allocator);
    value3.AddMember("value1", value1, allocator);        // 整个value1作为key的值
    value3.AddMember("value2", value2, allocator);        // 整个value2作为key的值

    // 转为string
    StringBuffer str;
    Writer<StringBuffer> writer(str);
    value3.Accept(writer);
    string strJson = str.GetString();
    cout << "value3:" << strJson.c_str() << endl;

}

记得在使用rapidjson是,对于string类型和数值类型,需要使用rapidjson的形式去封装,不然会出错

http://www.dinnco.com/news/83495.html

相关文章:

  • 网站关键词排名网络营销的策划流程
  • 温州网站托管全国新闻媒体发稿平台
  • 学做烘培的网站推广软件的app
  • 鄂州做网站河南网站seo
  • 上海服饰网站建设厦门人才网招聘最新信息
  • wordpress 固定链接设置企业网站优化公司
  • 短网址生成功能泰安seo培训
  • 中国建设银行春季招聘网站杭州网站关键词排名优化
  • 商务网站开发实验百度认证号码平台
  • html官方网站百度怎么投放广告
  • 合肥正规的seo公司衡水网站优化推广
  • 俄语网站里做外贸shop深圳网络营销渠道
  • 女的男的做那个视频网站百度收录量
  • 深圳网站设计公司哪家便宜淘宝如何刷关键词增加权重
  • 商务网站建设流程兰州seo公司
  • 查企业信息的国家网站seo优化报价
  • 网站开发的相关岗位推广普通话手抄报句子
  • 网站怎么做现场直播视频深圳网络运营推广公司
  • 做灯饰的企业都会在哪些网站百度文库账号登录入口
  • 做网站设计好的公司百度推广官方
  • 网站布局规范企业新闻营销
  • 无锡 网站建设公司seo方案怎么做
  • wordpress 网站加密广东疫情最新情况
  • 滁州市南谯区规划建设局网站公司推广方法有哪些
  • 烟台做外贸网站搜索引擎营销流程是什么?
  • 如何做好网站建设星链seo管理
  • 河东做网站的公司长沙岳麓区
  • 网站建设外包注意什么关键词调词平台
  • 贵阳市做网站的公司有哪些seo工具在线访问
  • flash cms网站源码排行榜