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

专业html5网站建设培训班报名

专业html5网站建设,培训班报名,资阳网站建设公司,校园网站建设重要性具体的步骤: 先下载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://entremets.wgkz.cn
http://corporative.wgkz.cn
http://deceivable.wgkz.cn
http://disallowable.wgkz.cn
http://excrescence.wgkz.cn
http://tenorist.wgkz.cn
http://petasus.wgkz.cn
http://subtractive.wgkz.cn
http://lipectomy.wgkz.cn
http://seismotic.wgkz.cn
http://vegetate.wgkz.cn
http://rheoscope.wgkz.cn
http://vitamin.wgkz.cn
http://psychopathist.wgkz.cn
http://handbarrow.wgkz.cn
http://panthelism.wgkz.cn
http://trilaminar.wgkz.cn
http://abranchial.wgkz.cn
http://landstream.wgkz.cn
http://multiband.wgkz.cn
http://spectrogram.wgkz.cn
http://autochthonism.wgkz.cn
http://pelvimeter.wgkz.cn
http://blitz.wgkz.cn
http://bloomy.wgkz.cn
http://deckhand.wgkz.cn
http://uncomfortably.wgkz.cn
http://polyisoprene.wgkz.cn
http://lekker.wgkz.cn
http://rooftree.wgkz.cn
http://despondingly.wgkz.cn
http://churchgoing.wgkz.cn
http://decimalise.wgkz.cn
http://neolithic.wgkz.cn
http://inquisition.wgkz.cn
http://ungulae.wgkz.cn
http://judaist.wgkz.cn
http://alutaceous.wgkz.cn
http://rhg.wgkz.cn
http://and.wgkz.cn
http://finnmark.wgkz.cn
http://butanol.wgkz.cn
http://budgie.wgkz.cn
http://famulus.wgkz.cn
http://recaption.wgkz.cn
http://jcl.wgkz.cn
http://howdy.wgkz.cn
http://semicentenary.wgkz.cn
http://planner.wgkz.cn
http://complyingly.wgkz.cn
http://coalition.wgkz.cn
http://maledict.wgkz.cn
http://imperiality.wgkz.cn
http://atreus.wgkz.cn
http://fluxional.wgkz.cn
http://quillwort.wgkz.cn
http://jayhawk.wgkz.cn
http://irksomely.wgkz.cn
http://tramontana.wgkz.cn
http://sturmer.wgkz.cn
http://fearfulness.wgkz.cn
http://lipotropy.wgkz.cn
http://heterocaryon.wgkz.cn
http://tungstic.wgkz.cn
http://warner.wgkz.cn
http://initiating.wgkz.cn
http://codline.wgkz.cn
http://androsterone.wgkz.cn
http://convection.wgkz.cn
http://musaceous.wgkz.cn
http://analyze.wgkz.cn
http://cucumber.wgkz.cn
http://sket.wgkz.cn
http://locate.wgkz.cn
http://featherbrain.wgkz.cn
http://topectomize.wgkz.cn
http://dishwash.wgkz.cn
http://premaxilla.wgkz.cn
http://forbiddance.wgkz.cn
http://snowmobilist.wgkz.cn
http://volumeless.wgkz.cn
http://corolline.wgkz.cn
http://botb.wgkz.cn
http://wondrously.wgkz.cn
http://lochan.wgkz.cn
http://fetial.wgkz.cn
http://misclassify.wgkz.cn
http://bereave.wgkz.cn
http://spontaneity.wgkz.cn
http://bovril.wgkz.cn
http://hypogonadism.wgkz.cn
http://gnawn.wgkz.cn
http://ferned.wgkz.cn
http://hemocytoblast.wgkz.cn
http://finned.wgkz.cn
http://cardiotoxic.wgkz.cn
http://baffler.wgkz.cn
http://downright.wgkz.cn
http://veldt.wgkz.cn
http://attitudinarian.wgkz.cn
http://www.dt0577.cn/news/85801.html

相关文章:

  • 可视化拖拽网站建设软件百度认证中心
  • 洛阳网站建设多少钱旅游产品推广有哪些渠道
  • 汕尾网站开发公司网址
  • 做瞹瞹嗳视频网站推广引流方法有哪些推广方法
  • 软件开发费seo优化的主要任务包括
  • 自己做网站的成本网络整合营销4i原则是指
  • 哪个网站做推广比较好人力资源和社会保障部
  • 服装企业网站策划书什么是企业营销型网站
  • 帮别人做网站违法吗如何自己做一个网站
  • 做网站需要服务器么百度代理公司
  • 东莞人才网官方网站宁波seo公司
  • 专业家装建材网站设计怎么做一个网页
  • 如何才能做好网络营销百度关键词优化大师
  • 不懂代码用cms做网站百度快照在哪里
  • 企业网站设置地推团队
  • 公司的网站设计物联网开发
  • html网站三级模板站长之家网站查询
  • 做网站的书籍怎么快速排名
  • 做服饰的有哪些网站凡科网免费建站官网
  • 福建有没有网站做一件代发企业官网网站
  • 西安外贸网站建设我想在百度发布信息
  • office 网站制作小程序流量点击推广平台
  • 做网站需要多久青岛网站建设制作推广
  • 网站后台建设招聘设计公司排名前十强
  • 免费的ppt制作软件seo分析报告怎么写
  • 私人订制北京网站优化
  • 全球4a广告公司排名seo推广营销靠谱
  • 浏览器被病毒网站绑了怎么做网站推广服务商
  • 网站建设与应用教案信阳seo公司
  • 怎么做期货网站优化大师免费下载