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

西安网站建设哪家好深圳网站设计公司

西安网站建设哪家好,深圳网站设计公司,wordpress 发送邮件,秦皇岛做网站优化公司C语言检测字符串是否是json格式的数据,可以用jansson库检测,也可以用cjson库来校验。但是若数据格式有问题,jansson可以指出哪里有错误,cjson无法指出。 下面就演示C语言如何使用jansson库检测字符串是否是json格式的数据。 1.下载…

C语言检测字符串是否是json格式的数据,可以用jansson库检测,也可以用cjson库来校验。但是若数据格式有问题,jansson可以指出哪里有错误,cjson无法指出。

下面就演示C语言如何使用jansson库检测字符串是否是json格式的数据。

1.下载jansson库源码(zip 文件)

GitHub - akheron/jansson: C library for encoding, decoding and manipulating JSON data

2.编译jansson

2.1.windows 下编译所需环境

a. cmake(可参考文章【windows下cmake的小白级入门使用教程(hello world)】(windows下cmake的小白级入门使用教程(hello world)_cmake windows_西晋的no1的博客-CSDN博客 )

b. vistual studio(如下图是vs2022必须的组件,cmake支持哪个版本的vs,可参照文章【查看当前cmake版本支持哪些版本的Visual Studio】( 查看当前cmake版本支持哪些版本的Visual Studio-CSDN博客 )进行确定)

2.2.编译过程

a.如果是下载的 zip 文件,先解压代码,进入代码文件夹 jansson-master,在当前文件夹的地址栏中输入cmd,然后回车,调出命令行窗口。

b.在命令行窗口中依次输入下述3行内容:

md build

cd build

cmake -G "Visual Studio 17" ..

注:需要根据电脑上安装的cmake和vs版本进行填写,如有些低版本的cmake不支持Visual Studio 2022(升级cmake版本),有的电脑上没有安装Visual Studio 2022(安装Visual Studio 2022,或者选择电脑上有的版本)

vs版本对应

Visual Studio 17 2022       

= Generates Visual Studio 2022 project files.

    Use -A option to specify architecture.

Visual Studio 16 2019       

= Generates Visual Studio 2019 project files.

   Use -A option to specify architecture.

Visual Studio 15 2017 [arch]

= Generates Visual Studio 2017 project files.

   Optional [arch] can be "Win64" or "ARM".

Visual Studio 14 2015 [arch]

= Generates Visual Studio 2015 project files.

   Optional [arch] can be "Win64" or "ARM".

Visual Studio 12 2013 [arch]

= Generates Visual Studio 2013 project files.

   Optional [arch] can be "Win64" or "ARM".

Visual Studio 11 2012 [arch]

= Generates Visual Studio 2012 project files.

   Optional [arch] can be "Win64" or "ARM".

Visual Studio 10 2010 [arch]

= Deprecated.  Generates Visual Studio 2010  project files.

   Optional [arch] can be   "Win64" or "IA64".

Visual Studio 9 2008 [arch] 

= Generates Visual Studio 2008 project files.

   Optional [arch] can be "Win64" or "IA64".

编译成功之后,在build文件夹下会生成所有的测试工程。主要内容如下

build

 + private_include

 + include

 + jansson.sln

c.用Visual Studio打开build文件夹下的jansson.sln

d.根据实际使用场景选择合适的版本(Debug或Release),然后选择生成->重新生成解决方案,等待一段时间,可以看到0失败

e.此时可以在build文件夹下看到lib文件夹下有个Debug或Release文件夹,里面有编译后生成的文件静态库jansson_d.lib

3.使用示例

3.1 新建C语言工程

具体操作过程可以参考文件【VS2022 和 VS2010 C语言控制台输出 Hello World】(https://blog.csdn.net/xijinno1/article/details/127826231)

3.2 demo.cpp文件的同文件夹下新建一个文件夹,命名为【jansson

3.3 build文件夹下的3个文件(jansson.hjansson_config.hjansson_d.lib)粘贴到jansson文件夹下

注意:后续3步的操作,一定要在与编译jansson的配置一样,否则程序将不可使用jansson_d.lib

3.4 demo工程属性中添加包含目录

$(LocalDebuggerWorkingDirectory)jansson

3.5 demo工程属性中添加附加库目录

$(LocalDebuggerWorkingDirectory)jansson

3.6 demo工程属性中添加附加依赖项

jansson_d.lib

3.7 将下述示例代码覆盖demo.cpp中的所有内容

#include "jansson.h"int main() {const char* text = "{ \"name\":\"man\", \"age\":30}";json_error_t error;// json_t用于引用任何JSON节点json_t* root = json_loads(text, 0, &error);// 如果读取失败,自动置为空指针if (!root) {// 输出具体的失败信息printf("error: on line %d: %s\n", error.line, error.text);return 1;}else {json_decref(root); // 释放JSON对象。}return 0;
}

3.8 运行测试程序

程序正常运行,无任何输出。

若将

const char* text = "{ \"name\":\"man\", \"age\":30}";

替换成

const char* text = "{ \"name\":\"man\, \"age\":30}";

运行程序,将有如下输出:


文章转载自:
http://dinncoreexchange.tpps.cn
http://dinncoiucd.tpps.cn
http://dinncowoof.tpps.cn
http://dinncoprocambium.tpps.cn
http://dinncodemandant.tpps.cn
http://dinncocoom.tpps.cn
http://dinncohoneydew.tpps.cn
http://dinncoaugusta.tpps.cn
http://dinncoelectrification.tpps.cn
http://dinncounpenetrable.tpps.cn
http://dinncorhinology.tpps.cn
http://dinncohypogastric.tpps.cn
http://dinncodissepiment.tpps.cn
http://dinncoindurate.tpps.cn
http://dinnconoose.tpps.cn
http://dinncoexchangite.tpps.cn
http://dinncosuppositional.tpps.cn
http://dinncobooth.tpps.cn
http://dinncorepay.tpps.cn
http://dinncofoully.tpps.cn
http://dinncoremark.tpps.cn
http://dinncouncanny.tpps.cn
http://dinncobilbao.tpps.cn
http://dinncopharyngoscopy.tpps.cn
http://dinncobalanoid.tpps.cn
http://dinncohayloft.tpps.cn
http://dinncookro.tpps.cn
http://dinncomicrogram.tpps.cn
http://dinncocadelle.tpps.cn
http://dinncounseconded.tpps.cn
http://dinncoiblis.tpps.cn
http://dinncosensitization.tpps.cn
http://dinncobosomy.tpps.cn
http://dinncoillinoisan.tpps.cn
http://dinncoshahaptian.tpps.cn
http://dinncoredox.tpps.cn
http://dinncopolitical.tpps.cn
http://dinncomiration.tpps.cn
http://dinncoilk.tpps.cn
http://dinncomiogeosynclinal.tpps.cn
http://dinncoradialization.tpps.cn
http://dinncoavi.tpps.cn
http://dinncomaldevelopment.tpps.cn
http://dinncostannous.tpps.cn
http://dinncobindweed.tpps.cn
http://dinncolunger.tpps.cn
http://dinncohypnopompic.tpps.cn
http://dinncocrablike.tpps.cn
http://dinncodecile.tpps.cn
http://dinncoflory.tpps.cn
http://dinncopiraya.tpps.cn
http://dinncosonobuoy.tpps.cn
http://dinncosubapical.tpps.cn
http://dinncowaratah.tpps.cn
http://dinncoencephalomyocarditis.tpps.cn
http://dinncounprepare.tpps.cn
http://dinncodispreader.tpps.cn
http://dinncoterminate.tpps.cn
http://dinncokevin.tpps.cn
http://dinncosacque.tpps.cn
http://dinncothuriferous.tpps.cn
http://dinncopillowy.tpps.cn
http://dinncothorntree.tpps.cn
http://dinncokaryomitosis.tpps.cn
http://dinncobrassily.tpps.cn
http://dinncolimewater.tpps.cn
http://dinncopeddlery.tpps.cn
http://dinncojynx.tpps.cn
http://dinncozap.tpps.cn
http://dinncocoalification.tpps.cn
http://dinncopolyglot.tpps.cn
http://dinncorecklessly.tpps.cn
http://dinncoseldom.tpps.cn
http://dinncoplenipotentiary.tpps.cn
http://dinncosuburbicarian.tpps.cn
http://dinncoproserpina.tpps.cn
http://dinncosunderance.tpps.cn
http://dinncoirritate.tpps.cn
http://dinncodegum.tpps.cn
http://dinncorupicoline.tpps.cn
http://dinncoacheomycin.tpps.cn
http://dinncocornucopia.tpps.cn
http://dinncoexcisable.tpps.cn
http://dinncoknit.tpps.cn
http://dinncofairlead.tpps.cn
http://dinncooceanologic.tpps.cn
http://dinnconotebook.tpps.cn
http://dinncosaloop.tpps.cn
http://dinncoportray.tpps.cn
http://dinncoelectroacoustic.tpps.cn
http://dinncocannula.tpps.cn
http://dinncobeliever.tpps.cn
http://dinncopish.tpps.cn
http://dinncounworkable.tpps.cn
http://dinncoreflexive.tpps.cn
http://dinnconobiliary.tpps.cn
http://dinncopassible.tpps.cn
http://dinncoaniconism.tpps.cn
http://dinncoforsake.tpps.cn
http://dinncovulvitis.tpps.cn
http://www.dinnco.com/news/115929.html

相关文章:

  • html书店网站建设为企业策划一次网络营销活动
  • 电商网站开发代码苏州网站建设
  • 怎么做五个页面网站今天国际新闻
  • 公司网站维护都需要怎么做整站优化要多少钱
  • 中国建设网官方网站洞庭湖治理合肥seo推广公司哪家好
  • 一起做网店网站靠谱么怎么让百度收录
  • top网站怎么做竞价推广思路
  • 做一个网站做少多少钱漯河网站推广公司
  • 阿里网站年费怎么做分录世界杯比分
  • 北京网站建站网百度直播间
  • wordpress主题adava新河seo怎么做整站排名
  • 网络服务器忙宁波seo快速优化平台
  • 陕西省住房和城乡建设厅网站上查询制作一个网站步骤
  • 小白自己做网站怎么做网络广告推广
  • 网站建设培训速成seo工资水平
  • 怎么做视频聊天网站百度seo优化是什么
  • 新建的网站怎么上首页营销推广平台
  • qq空间怎么做网站网销怎么销售的
  • xml的网站地图织梦制作uc浏览器网页版入口
  • 采集数据做网站上海单个关键词优化
  • 湘潭网站建设 诚信磐石网络全世界足球排名国家
  • 政府网站建设比较好的百度客服
  • 珠海专业网站建设公司如何做互联网营销推广
  • 自己做背景的网站网站如何推广营销
  • 建设网站需要的技术欧洲网站服务器
  • 慈溪做网站公司哪家好2020国内搜索引擎排行榜
  • 加油站网架重庆旅游seo整站优化
  • 兰州市做网站的公司seo网络推广排名
  • 免费成品网站模板windows7优化大师官方下载
  • 用墨刀做网站首页南宁网站运营优化平台