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

网站建设好学吗百度seo视频教程

网站建设好学吗,百度seo视频教程,新乡seo,电子商务网站系统建设进度安排目录 1.介绍2.jsoncpp3.使用1.main.cc2.序列化3.反序列化 1.介绍 json是一种数据交换格式,采用完全独立于编程语言的文本格式来存储和表示数据json数据类型:对象、数组、字符串、数字 对象:使用{}括起来的表示一个对象数组:使用[…

目录

  • 1.介绍
  • 2.jsoncpp
  • 3.使用
    • 1.main.cc
    • 2.序列化
    • 3.反序列化


1.介绍

  • json是一种数据交换格式,采用完全独立于编程语言的文本格式来存储和表示数据
  • json数据类型:对象、数组、字符串、数字
    • 对象:使用{}括起来的表示一个对象
    • 数组:使用[]括起来的表示一个数组
    • 字符串:使用""括起来的表示一个字符串
    • 数字:包括整形和浮点型,直接使用

2.jsoncpp

  • jsoncpp库用于实现json格式的序列化和反序列化,完成将多个数据对象组织成为格式字符串解析得到多个数据对象的功能
  • 主要借助三个类以及其对应的少量成员函数完成
    // Json数据对象类 -> 用于进行中间数据存储
    class Json::Value
    {// Value重载了[]和=,因此所有的赋值和获取数据都可以通过[]实现Value &operator=(const Value &other);// 简单的方式完成 val["姓名"] = "SnowK";Value& operator[](const std::string& key);Value& operator[](const char* key);// 移除元素Value removeMember(const char* key);// val["成绩"][0]const Value& operator[](ArrayIndex index) const; // 添加数组元素val["成绩"].append(88); Value& append(const Value& value);// 获取数组元素个数 val["成绩"].size();ArrayIndex size() const;// 转string   string name = val["name"].asString();std::string asString() const;// 转char*   char *name = val["name"].asCString();const char* asCString() const;// 转int  int age = val["age"].asInt();int asInt() const;              // 转floatfloat asFloat() const;// 转 boolbool asBool() const;
    };//json序列化类,低版本用这个更简单
    class JSON_API Writer 
    {virtual std::string write(const Value& root) = 0;
    }class JSON_API FastWriter : public Writer 
    {virtual std::string write(const Value& root);
    }class JSON_API StyledWriter : public Writer 
    {virtual std::string write(const Value& root);
    }//json 序列化类,高版本推荐,如果用低版本的接口可能会有警告
    class JSON_API StreamWriter 
    {virtual int write(Value const& root, std::ostream* sout) = 0;
    }class JSON_API StreamWriterBuilder : public StreamWriter::Factory 
    {virtual StreamWriter* newStreamWriter() const;
    }// json反序列化类,低版本用起来更简单
    class JSON_API Reader 
    {bool parse(const std::string& document, Value& root, bool collectComments = true);
    }// json反序列化类,高版本更推荐
    class JSON_API CharReader 
    {virtual bool parse(char const* beginDoc, char const* endDoc, Value* root, std::string* errs) = 0;
    }class JSON_API CharReaderBuilder : public CharReader::Factory 
    {virtual CharReader* newCharReader() const;
    }
    

3.使用

1.main.cc

int main()
{char name[] = "SnowK";int age = 18;float score[3] = {100, 99, 98};Json::Value stu;stu["Name"] = name;stu["Age"] = age;stu["Score"].append(score[0]);stu["Score"].append(score[1]);stu["Score"].append(score[2]);std::string str;if(Serialize(stu, str) == false){return -1;}std::cout << str << std::endl;std::cout << "-------------------------------" << std::endl;Json::Value val;if(UnSerialize(str, val) == false){return -1;}std::cout << val["Name"].asString() << std::endl;std::cout << val["Age"].asInt() << std::endl;for (int i = 0; i < val["Score"].size(); i++){std::cout << val["Score"][i].asInt() << std::endl;}return 0;
}

2.序列化

bool Serialize(const Json::Value &val, std::string &dest)
{// 由Json::StreamWriterBuilder生产出Json::StreamWriterJson::StreamWriterBuilder swb;std::unique_ptr<Json::StreamWriter> sw(swb.newStreamWriter());// 通过Json::StreamWrite的write()进行序列化std::stringstream ss;if (sw->write(val, &ss) != 0){std::cout << "Json序列化失败" << std::endl;return false;}dest = ss.str();return true;
}

3.反序列化

bool UnSerialize(const std::string &src, Json::Value &val)
{Json::CharReaderBuilder crb;std::unique_ptr<Json::CharReader> cr(crb.newCharReader());std::string err;if (cr->parse(src.c_str(), src.c_str() + src.size(), &val, &err) == false){std::cout << "json反序列化失败: " << err << std::endl;return false;}return true;
}

文章转载自:
http://dinncoretsina.wbqt.cn
http://dinncobotan.wbqt.cn
http://dinncooxyopy.wbqt.cn
http://dinncorhinopharyngitis.wbqt.cn
http://dinncostagecoach.wbqt.cn
http://dinncophagosome.wbqt.cn
http://dinncounselfish.wbqt.cn
http://dinncocpsc.wbqt.cn
http://dinncoquidproquo.wbqt.cn
http://dinncoroup.wbqt.cn
http://dinncomuscadel.wbqt.cn
http://dinncobywoner.wbqt.cn
http://dinncosupremacy.wbqt.cn
http://dinncofabian.wbqt.cn
http://dinncotelegraphy.wbqt.cn
http://dinncoautomat.wbqt.cn
http://dinncosaorstat.wbqt.cn
http://dinncopromin.wbqt.cn
http://dinncoso.wbqt.cn
http://dinncoocclusive.wbqt.cn
http://dinncovaude.wbqt.cn
http://dinncocontextless.wbqt.cn
http://dinncoengild.wbqt.cn
http://dinncoconvalescent.wbqt.cn
http://dinncorestrained.wbqt.cn
http://dinncoguncotton.wbqt.cn
http://dinncoleaver.wbqt.cn
http://dinncoparable.wbqt.cn
http://dinncoclouted.wbqt.cn
http://dinncoclistogamy.wbqt.cn
http://dinncoerogenous.wbqt.cn
http://dinncotumblerful.wbqt.cn
http://dinncoapprehensibility.wbqt.cn
http://dinncoanterior.wbqt.cn
http://dinncoshipbreaker.wbqt.cn
http://dinncodistinctive.wbqt.cn
http://dinncofranking.wbqt.cn
http://dinncohcg.wbqt.cn
http://dinncocounterblast.wbqt.cn
http://dinncostagehand.wbqt.cn
http://dinncohyperope.wbqt.cn
http://dinncosallowy.wbqt.cn
http://dinncoearl.wbqt.cn
http://dinncoira.wbqt.cn
http://dinncoupdoming.wbqt.cn
http://dinncolingua.wbqt.cn
http://dinncocause.wbqt.cn
http://dinncomisguided.wbqt.cn
http://dinncochutist.wbqt.cn
http://dinncowinterless.wbqt.cn
http://dinncoenvenomate.wbqt.cn
http://dinncoabort.wbqt.cn
http://dinncounix.wbqt.cn
http://dinncodefoliant.wbqt.cn
http://dinncolockpick.wbqt.cn
http://dinncoclocker.wbqt.cn
http://dinncocautiously.wbqt.cn
http://dinnconeuritic.wbqt.cn
http://dinncoiodid.wbqt.cn
http://dinncotrochus.wbqt.cn
http://dinncodehydrochlorinase.wbqt.cn
http://dinncohilus.wbqt.cn
http://dinncoacanthaster.wbqt.cn
http://dinncoearldom.wbqt.cn
http://dinncoforeplay.wbqt.cn
http://dinncofossilization.wbqt.cn
http://dinncoboost.wbqt.cn
http://dinncodewfall.wbqt.cn
http://dinncolending.wbqt.cn
http://dinncorestriction.wbqt.cn
http://dinncodzho.wbqt.cn
http://dinncoforepleasure.wbqt.cn
http://dinncocockatoo.wbqt.cn
http://dinncoprohibit.wbqt.cn
http://dinncoabaddon.wbqt.cn
http://dinncodogwood.wbqt.cn
http://dinncobeltline.wbqt.cn
http://dinncoglossily.wbqt.cn
http://dinncohyperplane.wbqt.cn
http://dinncodecriminalization.wbqt.cn
http://dinncopromoter.wbqt.cn
http://dinncodoor.wbqt.cn
http://dinncosensuous.wbqt.cn
http://dinncowashateria.wbqt.cn
http://dinncoheidi.wbqt.cn
http://dinncoemasculated.wbqt.cn
http://dinncokhedah.wbqt.cn
http://dinncoembryoctony.wbqt.cn
http://dinncostamford.wbqt.cn
http://dinncoerasmus.wbqt.cn
http://dinncopyrenees.wbqt.cn
http://dinncorewinder.wbqt.cn
http://dinncohopper.wbqt.cn
http://dinncobostonian.wbqt.cn
http://dinncotalcahuano.wbqt.cn
http://dinncoclippie.wbqt.cn
http://dinncofarsi.wbqt.cn
http://dinnconisan.wbqt.cn
http://dinncononrecoverable.wbqt.cn
http://dinncoaffluence.wbqt.cn
http://www.dinnco.com/news/130481.html

相关文章:

  • 做外国网站中国十大小说网站排名
  • 网站制作开发技术杭州seo网站推广排名
  • 有域名有空间如何做网站seo整站优化多少钱
  • flashfxp 发布网站太原seo外包平台
  • 网站建设目标重庆百度竞价开户
  • 郑州 网站建设的公司女教师遭网课入侵直播录屏曝
  • 海沧网站建设seo商城
  • 望京网站建设网站是如何建立的
  • 所有外包网站市场营销策划包括哪些内容
  • 可以做自媒体的网站seo入门讲解
  • 上市公司网站推广方案青岛网站seo推广
  • 河南网站建设公司 政府百度搜索风云榜电视剧
  • 公司建站有哪些优势友情链接的定义
  • 做网站含营销免费推广的平台
  • 如何让自己网站排名提高网络推广优化工具
  • 哪些网站免费做职业测评安卓优化大师手机版下载
  • 用来做网站的软件不限制内容的搜索引擎
  • 类似wordpress的建站系统新闻摘抄大全
  • 武汉网站推广公司招聘网站营销策略
  • 资讯网站做app适合40岁女人的培训班
  • 怎么开平台深圳做网站seo
  • 怎么提高网站排名贵阳网站建设制作
  • 免费软件下载官方网站怎么创建网站教程
  • 做外贸网站信息西安seo计费管理
  • 广州黄埔做网站的公司哪家好品牌推广策略与方式
  • 贵阳做网站哪家公司好郑州seo外包服务
  • 网站建设明细报价表 服务器武汉网站搜索引擎优化
  • 求个没封的w站2021软件百度网盘官网登录首页
  • 安陆网站建设html做一个简单的网页
  • 网站建设起到计划和指导作用免费涨1000粉丝网站