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

云南网站建设哪家权威海南百度推广公司有哪些

云南网站建设哪家权威,海南百度推广公司有哪些,江西网站设计哪家好,国外外包平台什么是JSON JSON是一种轻量级的数据交换格式,可读性强、编写简单。键值对组合编写规则,键名使用双引号包裹,冒号:分隔符后面紧跟着数值,有两种常用的数据类型是对象和数组。 对象:使用花括号{}包裹起来的…

什么是JSON

JSON是一种轻量级的数据交换格式,可读性强、编写简单。键值对组合编写规则,键名使用双引号包裹,冒号:分隔符后面紧跟着数值,有两种常用的数据类型是对象和数组。

对象:使用花括号{}包裹起来的内容,数据结构{“key1”: “value1”, “key2”:“value2” …},key为对象的属性,value为对象的值。

数值:使用中括号[]包裹起来的内容,数据结构{“key”: [“value1”, “value2”, “value3” …]}。
 

CentOS 7 安装cJSON 库

cJSON Github 地址:https://github.com/DaveGamble/cJSON

步骤1:首先,你需要下载cJSON的源代码。你可以从https://github.com/DaveGamble/cJSON或者源代码官方网站下载。并上传至/usr/local/source_code/  

步骤2:下载完成后,需要将源代码解压,可以使用以下命令: 

[root@localhost source_code]# tar -zxvf cJSON-1.7.15.tar.gz

 步骤3:解压后,切换到源代码目录: 

[root@localhost source_code]# cd cJSON-1.7.15

步骤4:生成cJSON动态/静态库,执行如下指令: 

[root@localhost cJSON-1.7.15]# mkdir build
[root@localhost cJSON-1.7.15]# cd build/
[root@localhost build]# cmake ..
CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):Compatibility with CMake < 2.8.12 will be removed from a future version ofCMake.Update the VERSION argument <min> value or use a ...<max> suffix to tellCMake that the project does not need compatibility with older versions.-- The C compiler identification is GNU 8.3.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
******
[root@localhost build]# make && make install
[  2%] Building C object CMakeFiles/cjson.dir/cJSON.c.o
[  4%] Linking C shared library libcjson.so
[  4%] Built target cjson
[  6%] Building C object CMakeFiles/cJSON_test.dir/test.c.o
[  8%] Linking C executable cJSON_test
[  8%] Built target cJSON_test
[ 11%] Building C object tests/CMakeFiles/unity.dir/unity/src/unity.c.o
[ 13%] Linking C static library libunity.a
[ 13%] Built target unity
[ 15%] Building C object tests/CMakeFiles/print_number.dir/print_number.c.o
[ 17%] Linking C executable print_number
-- 省略--
[100%] Built target fuzz_main
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/include/cjson/cJSON.h
-- Installing: /usr/local/lib64/pkgconfig/libcjson.pc
-- Installing: /usr/local/lib64/libcjson.so.1.7.15
-- Installing: /usr/local/lib64/libcjson.so.1
-- Installing: /usr/local/lib64/libcjson.so
-- Installing: /usr/local/lib64/cmake/cJSON/cjson.cmake
-- Installing: /usr/local/lib64/cmake/cJSON/cjson-noconfig.cmake
-- Installing: /usr/local/lib64/cmake/cJSON/cJSONConfig.cmake
-- Installing: /usr/local/lib64/cmake/cJSON/cJSONConfigVersion.cmake

遇到的问题及解决办法

编译执行./test_cjson,提示如下截图错误信息:

[root@localhost cJSON_demo]# ./test_cjson
./test_cjson: error while loading shared libraries: libcjson.so.1: cannot open shared object file: No such file or directory

从报错的原因上看,本机上没有找到cJOSN类库的静态库/动态库libcjson.so。

首先检查/usr/local/lib 和/usr/local/include 目录中是否包含cjson 静态或动态库,可以执行如下指令:

ls /usr/local/lib | grep cjson
ls /usr/local/include | grep cjson

从上面分组 查询结果可知:cjson 没有在/usr/local/lib 库中生成cjson 静态/动态库链接。

再次查看cJOSN 在执行make && make install 指令时,对应cJSON 静态/动态库生成链接存放目录地址。

从上述截图可知cJSON 静态/动态库被安装到了/usr/local/lib64 目录中。

将/usr/local/lib64 目录添加至本机静态/动态库链接目录文件中,执行如下指令:

[root@localhost cJSON_demo]# cat /etc/ld.so.conf.d/usr-libs.conf
/usr/local/lib
[root@localhost cJSON_demo]# vi /etc/ld.so.conf.d/usr-libs.conf
[root@localhost ~]#  cat /etc/ld.so.conf.d/usr-libs.conf
/usr/local/lib
/usr/local/lib64
[root@localhost cJSON_demo]# sudo ldconfig

再次编译执行./test_cjson, Main 函数正确输出。

cJSON快速入门

在/usr/local/source_code 新增 cJSON_demo目录并新增test_cjson.c 文件,文件内容如下:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cjson/cJSON.h>int main()
{cJSON *json = NULL;cJSON *node = NULL;cJSON *tnode = NULL;cJSON *tnode2 = NULL;char *json_data = NULL;int i, j, size, size2;char *data = "{\"serialNumber\":\"212089842348362300\", \\"cellularInfo\":\[\{\"name\":\"ethernet0/0/1\",\\"switch\":\"0\"},\{\"name\":\"ethernet0/0/2\",\\"switch\":\"1\"},\{\"name\":\"ethernet0/0/3\",\\"switch\":\"0\"}\],\\"family\":[\"father\",\"mother\",\"brother\",\"sister\",\"somebody\"]\}";json = cJSON_Parse(data);json_data = cJSON_Print(json);printf("data: %s\n", json_data);free(json_data);node = cJSON_GetObjectItem(json,"serialNumber");if(node == NULL)printf("serialNumber: no\n");elseprintf("serialNumber: ok\n");node = cJSON_GetObjectItem(json, "family");if (node == NULL)printf("family: no\n");elseprintf("family: ok\n");if (node->type == cJSON_Array){printf("family array size is %d\n", cJSON_GetArraySize(node));size = cJSON_GetArraySize(node);for (i=0; i<size; i++){tnode = cJSON_GetArrayItem(node, i);if (tnode->type == cJSON_String)printf("%d: %s\n", i, tnode->valuestring);elseprintf("node type is not string, value = %d\n", tnode->type);}}node = cJSON_GetObjectItem(json, "cellularInfo");if(node == NULL)printf("cellularInfo: no\n");elseprintf("cellularInfo: ok\n");if (node->type == cJSON_Array){printf("cellularInfo array size is %d\n", cJSON_GetArraySize(node));size = cJSON_GetArraySize(node);for (i=0; i<size; i++){tnode = cJSON_GetArrayItem(node, i);if (tnode->type == cJSON_String)printf("%d: %s\n", i, tnode->valuestring);else if (tnode->type == cJSON_Object){size2 = cJSON_GetArraySize(tnode);for (j=0; j<size2; j++){tnode2 = cJSON_GetArrayItem(tnode, j);if (tnode2->type == cJSON_String)printf("%d-%d: %s\n", i, j, tnode2->valuestring);elseprintf("tnod2 type is err\n");}}elseprintf("node type is not string, value = %d\n", tnode->type);}}cJSON_Delete(json);return 0;
}

编译源码并执行:

[root@localhost cJSON_demo]# gcc -o test_cjson test_cjson.c -lcjson
[root@localhost cJSON_demo]# ./test_cjson
data: {"serialNumber": "212089842348362300","cellularInfo": [{"name": "ethernet0/0/1","switch":       "0"}, {"name": "ethernet0/0/2","switch":       "1"}, {"name": "ethernet0/0/3","switch":       "0"}],"family":       ["father", "mother", "brother", "sister", "somebody"]
}
serialNumber: ok
family: ok
family array size is 5
0: father
1: mother
2: brother
3: sister
4: somebody
cellularInfo: ok
cellularInfo array size is 3
0-0: ethernet0/0/1
0-1: 0
1-0: ethernet0/0/2
1-1: 1
2-0: ethernet0/0/3
2-1: 0

cJSON 参考资料

cJSON Github 官网地址:https://github.com/DaveGamble/cJSON

cJSON 开发参考: https://zhuanlan.zhihu.com/p/55095477?utm_oi=892471685738024960


文章转载自:
http://zoophorus.gtqx.cn
http://damnable.gtqx.cn
http://priggism.gtqx.cn
http://laypeople.gtqx.cn
http://tangleberry.gtqx.cn
http://encircle.gtqx.cn
http://thereafter.gtqx.cn
http://abraxas.gtqx.cn
http://smileless.gtqx.cn
http://manwards.gtqx.cn
http://archdeaconship.gtqx.cn
http://minitype.gtqx.cn
http://bindweed.gtqx.cn
http://bestiality.gtqx.cn
http://nesselrode.gtqx.cn
http://ineluctable.gtqx.cn
http://imprest.gtqx.cn
http://interphase.gtqx.cn
http://motorise.gtqx.cn
http://perve.gtqx.cn
http://ipsu.gtqx.cn
http://circular.gtqx.cn
http://pommern.gtqx.cn
http://scheduling.gtqx.cn
http://zaftig.gtqx.cn
http://nonsingular.gtqx.cn
http://sheerlegs.gtqx.cn
http://panel.gtqx.cn
http://wealthy.gtqx.cn
http://unaec.gtqx.cn
http://qanat.gtqx.cn
http://pest.gtqx.cn
http://thir.gtqx.cn
http://civvies.gtqx.cn
http://fedora.gtqx.cn
http://medaled.gtqx.cn
http://hematoid.gtqx.cn
http://leewardmost.gtqx.cn
http://angiotomy.gtqx.cn
http://hostly.gtqx.cn
http://antianxity.gtqx.cn
http://delusion.gtqx.cn
http://jazzily.gtqx.cn
http://mmm.gtqx.cn
http://hyperbola.gtqx.cn
http://anelastic.gtqx.cn
http://vagi.gtqx.cn
http://rheidity.gtqx.cn
http://outfitter.gtqx.cn
http://corporeally.gtqx.cn
http://may.gtqx.cn
http://hotch.gtqx.cn
http://overvoltage.gtqx.cn
http://unexceptional.gtqx.cn
http://joking.gtqx.cn
http://roundheaded.gtqx.cn
http://profusive.gtqx.cn
http://sphinges.gtqx.cn
http://aquosity.gtqx.cn
http://filmable.gtqx.cn
http://galax.gtqx.cn
http://henbane.gtqx.cn
http://variably.gtqx.cn
http://wordsplitting.gtqx.cn
http://faro.gtqx.cn
http://ccw.gtqx.cn
http://em.gtqx.cn
http://strassburg.gtqx.cn
http://unfounded.gtqx.cn
http://scraping.gtqx.cn
http://commie.gtqx.cn
http://winning.gtqx.cn
http://tightfisted.gtqx.cn
http://roam.gtqx.cn
http://uricase.gtqx.cn
http://career.gtqx.cn
http://analcime.gtqx.cn
http://holeproof.gtqx.cn
http://meteor.gtqx.cn
http://appointee.gtqx.cn
http://plume.gtqx.cn
http://homologous.gtqx.cn
http://reargument.gtqx.cn
http://darkey.gtqx.cn
http://preaseptic.gtqx.cn
http://hypersomnia.gtqx.cn
http://interlibrary.gtqx.cn
http://nonpros.gtqx.cn
http://radiolabel.gtqx.cn
http://sabina.gtqx.cn
http://finicking.gtqx.cn
http://picked.gtqx.cn
http://consuela.gtqx.cn
http://paramagnetic.gtqx.cn
http://diascope.gtqx.cn
http://manipulate.gtqx.cn
http://combinatory.gtqx.cn
http://capework.gtqx.cn
http://hurtlingly.gtqx.cn
http://sonagraph.gtqx.cn
http://www.15wanjia.com/news/75448.html

相关文章:

  • 北京设计院排名100强长沙seo结算
  • 关于做膳食的一些网站抚顺网络推广
  • 上海高端模板建站网站是怎么做的
  • wordpress表单功能新手如何学seo
  • 网站服务器是干什么的网络优化公司有哪些
  • 电子商务有什么岗位杭州seo教程
  • 网站实现隶书繁体网络广告文案范文
  • 崇明网站建设建什么网站可以长期盈利
  • 云南网站建设方案上海哪家优化公司好
  • 怎样申请一个免费网站推广软文怎么写样板
  • 网站域名 空间申请表百度收录查询网址
  • 做婚介打么网站好徐州百度推广电话
  • 成人做暧视频观看网站市场推广方案范文
  • 怎么注册网站个人互联网营销课程体系
  • 淘宝网站开发海南seo
  • 怎么做一个网站怎么样如何查询百度收录
  • 简述网站建设的步骤郑州seo服务
  • 东盟建设投资有限公司网站北京网站优化公司
  • 网站架设工具网络营销经典失败案例
  • 电竞竞猜网站 建设福州百度seo
  • 运营 网站目前小说网站排名
  • 做救助流浪动物网站的产生背景网络推广怎样做
  • top的域名网站别做网络推广员
  • 在线旅游攻略网站建设方案重庆seo网站推广优化
  • icp备案查询官方网站内蒙古最新消息
  • 福州网站建设新闻排名软件
  • 镇江网站优化推广百度推广怎么操作流程
  • 临沂免费做网站百度怎么推广网站
  • 代做网站和说明书竞价推广员月挣多少
  • 营销型企业网站建设的基本原则是百度如何免费推广