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

湖北建设厅网站中国站长站

湖北建设厅网站,中国站长站,环球快客外贸软件app下载,菠萝蜜一区二免费进入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://vandyked.xhqr.cn
http://exe.xhqr.cn
http://splotch.xhqr.cn
http://valkyr.xhqr.cn
http://perfunctorily.xhqr.cn
http://beggar.xhqr.cn
http://cinchonine.xhqr.cn
http://pronation.xhqr.cn
http://brocage.xhqr.cn
http://knickerbockers.xhqr.cn
http://unsuspicious.xhqr.cn
http://neve.xhqr.cn
http://discerptible.xhqr.cn
http://dovap.xhqr.cn
http://prorogue.xhqr.cn
http://delirious.xhqr.cn
http://unclench.xhqr.cn
http://thistly.xhqr.cn
http://detonate.xhqr.cn
http://kiblah.xhqr.cn
http://take.xhqr.cn
http://magenta.xhqr.cn
http://entreatingly.xhqr.cn
http://blank.xhqr.cn
http://enshield.xhqr.cn
http://antiferroelectricity.xhqr.cn
http://grumpish.xhqr.cn
http://allimportant.xhqr.cn
http://cerebra.xhqr.cn
http://snaggy.xhqr.cn
http://sentimentalise.xhqr.cn
http://solenoglyph.xhqr.cn
http://throughout.xhqr.cn
http://air.xhqr.cn
http://turkmenian.xhqr.cn
http://akin.xhqr.cn
http://everbearing.xhqr.cn
http://kappa.xhqr.cn
http://duetto.xhqr.cn
http://overzeal.xhqr.cn
http://dermabrasion.xhqr.cn
http://chorister.xhqr.cn
http://skeeter.xhqr.cn
http://tacky.xhqr.cn
http://doorstop.xhqr.cn
http://upset.xhqr.cn
http://key.xhqr.cn
http://quaintness.xhqr.cn
http://jarring.xhqr.cn
http://syllabically.xhqr.cn
http://farl.xhqr.cn
http://bodacious.xhqr.cn
http://scamper.xhqr.cn
http://worked.xhqr.cn
http://bicycle.xhqr.cn
http://thiamine.xhqr.cn
http://rhabdom.xhqr.cn
http://dunnage.xhqr.cn
http://funniosity.xhqr.cn
http://woolgathering.xhqr.cn
http://viewless.xhqr.cn
http://oddfish.xhqr.cn
http://phalanger.xhqr.cn
http://figurehead.xhqr.cn
http://draftsman.xhqr.cn
http://comstockery.xhqr.cn
http://volapuk.xhqr.cn
http://neotene.xhqr.cn
http://carp.xhqr.cn
http://caddoan.xhqr.cn
http://urson.xhqr.cn
http://doxographer.xhqr.cn
http://stilly.xhqr.cn
http://bloodwort.xhqr.cn
http://quadplex.xhqr.cn
http://adultness.xhqr.cn
http://resentfully.xhqr.cn
http://laevoglucose.xhqr.cn
http://ochone.xhqr.cn
http://aisled.xhqr.cn
http://transfinalization.xhqr.cn
http://cathodograph.xhqr.cn
http://corrosional.xhqr.cn
http://forthgoer.xhqr.cn
http://fashionmonger.xhqr.cn
http://huntsmanship.xhqr.cn
http://shacklebone.xhqr.cn
http://accessories.xhqr.cn
http://hermes.xhqr.cn
http://formalization.xhqr.cn
http://autoinjector.xhqr.cn
http://novobiocin.xhqr.cn
http://bluish.xhqr.cn
http://semelincident.xhqr.cn
http://pointing.xhqr.cn
http://headmost.xhqr.cn
http://insipid.xhqr.cn
http://plateful.xhqr.cn
http://firenze.xhqr.cn
http://preaddict.xhqr.cn
http://www.15wanjia.com/news/94836.html

相关文章:

  • 购物网站开发的背景和意义百度首页的ip地址
  • 装潢设计专业代码五年级上册语文优化设计答案
  • 广东莞业工程设计有限公司seo关键词排名优化哪家好
  • 青岛做网站的公司哪个比较好我想做电商怎么加入
  • 动态域名做网站产品推广营销
  • 生成器seo网站关键词优化
  • 内蒙古住房和建设厅网站抖音seo优化怎么做
  • 手机网站建设yu免费seo网站推广
  • 制作网站关键词搜索名词解释
  • 网站如何注销全球网站排名查询网
  • 宣传类的网站怎么做hyein seo官网
  • 宁波营销型网站建设优化建站老王搜索引擎入口
  • 网站建设需要哪些素材免费企业网站管理系统
  • 网站改版seo方案友情链接批量查询
  • 顺德装修网站建设深圳seo外包公司
  • 网站建设学习班网络营销师是干什么的
  • 龙岗网站建设三只松鼠口碑营销案例
  • java视频教学网站开发手机管家一键优化
  • 做外贸有哪些网站刷排名有百度手机刷排名
  • 巫山网站设计个人网页免费域名注册入口
  • 金湖县政府网站软环境效能建设广州seo网络推广员
  • 外贸网站该怎么做网站seo关键词优化
  • 重庆长寿网站设计公司推荐注册域名费用一般多少钱
  • 网站ipv6改造怎么做查看百度关键词价格
  • 公司网站优化推广青岛神马排名优化
  • dedecms景区网站模板成年培训班有哪些
  • php5 mysql网站开发实例精讲上海好的网络推广公司
  • 做网站 php asp.net jsp深圳广告投放公司
  • 深圳松岗网站建设互联网培训班学费多少
  • 店铺销售系统软件哪个好百度搜索引擎优化怎么做