资源简介
STM32环境中,C语言实现JSON

代码片段和文件信息
/*
Copyright (c) 2009 Dave Gamble
Permission is hereby granted free of charge to any person obtaining a copy
of this software and associated documentation files (the “Software“) to deal
in the Software without restriction including without limitation the rights
to use copy modify merge publish distribute sublicense and/or sell
copies of the Software and to permit persons to whom the Software is
furnished to do so subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND EXPRESS OR
IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER
LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING FROM
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* cJSON */
/* JSON parser in C. */
#include
#include
#include
#include
#include
#include
#include
#include “cJSON.h“
#include “malloc.h“
static const char *ep;
const char *cJSON_GetErrorPtr(void) {return ep;}
static int cJSON_strcasecmp(const char *s1const char *s2)
{
if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
for(; tolower(*s1) == tolower(*s2); ++s1 ++s2) if(*s1 == 0) return 0;
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
}
static void *(*cJSON_malloc)(size_t sz) = mymalloc;
static void (*cJSON_free)(void *ptr) = myfree;
static char* cJSON_strdup(const char* str)
{
size_t len;
char* copy;
len = strlen(str) + 1;
if (!(copy = (char*)cJSON_malloc(len))) return 0;
memcpy(copystrlen);
return copy;
}
void cJSON_InitHooks(cJSON_Hooks* hooks)
{
if (!hooks) { /* Reset hooks */
cJSON_malloc = malloc;
cJSON_free = free;
return;
}
cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc;
cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
}
/* Internal constructor. */
static cJSON *cJSON_New_Item(void)
{
cJSON* node = (cJSON*)cJSON_malloc(sizeof(cJSON));
if (node) memset(node0sizeof(cJSON));
return node;
}
/* Delete a cJSON structure. */
void cJSON_Delete(cJSON *c)
{
cJSON *next;
while (c)
{
next=c->next;
if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child);
if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring);
if (c->string) cJSON_free(c->string);
cJSON_free(c);
c=next;
}
}
/* Parse the input text to generate a number and populate the result into item. */
static const char *parse_number(cJSON *itemconst char *num)
{
double n=0sign=1scale=0;int subscale=0signsubscale=1;
if (*num==‘-‘) sign=-1num++; /* Has sign
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-11-23 10:14 stm32_cjson\
目录 0 2014-11-23 10:00 stm32_cjson\cJSON\
文件 23200 2014-11-23 10:00 stm32_cjson\cJSON\cJSON.c
文件 6833 2014-11-21 12:29 stm32_cjson\cJSON\cJSON.h
文件 1091 2013-08-14 14:02 stm32_cjson\cJSON\LICENSE
文件 8751 2009-10-28 23:48 stm32_cjson\cJSON\README
文件 6573 2013-02-09 12:56 stm32_cjson\cJSON\test.c
目录 0 2013-08-14 14:21 stm32_cjson\cJSON\tests\
文件 583 2009-08-23 23:46 stm32_cjson\cJSON\tests\test1
文件 242 2009-08-23 23:46 stm32_cjson\cJSON\tests\test2
文件 605 2009-08-23 23:46 stm32_cjson\cJSON\tests\test3
文件 3467 2009-08-23 23:47 stm32_cjson\cJSON\tests\test4
文件 873 2009-08-23 23:47 stm32_cjson\cJSON\tests\test5
目录 0 2012-07-22 11:07 stm32_cjson\CMSIS\
文件 17273 2010-06-07 10:25 stm32_cjson\CMSIS\core_cm3.c
文件 85714 2011-02-09 14:59 stm32_cjson\CMSIS\core_cm3.h
目录 0 2012-07-22 11:07 stm32_cjson\CMSIS\startup\
文件 15766 2011-03-10 10:52 stm32_cjson\CMSIS\startup\startup_stm32f10x_cl.s
文件 15503 2011-03-10 10:52 stm32_cjson\CMSIS\startup\startup_stm32f10x_hd.s
文件 15692 2011-03-10 10:52 stm32_cjson\CMSIS\startup\startup_stm32f10x_hd_vl.s
文件 12376 2011-03-10 10:52 stm32_cjson\CMSIS\startup\startup_stm32f10x_ld.s
文件 13656 2011-03-10 10:52 stm32_cjson\CMSIS\startup\startup_stm32f10x_ld_vl.s
文件 12765 2011-03-10 10:52 stm32_cjson\CMSIS\startup\startup_stm32f10x_md.s
文件 14073 2011-03-10 10:51 stm32_cjson\CMSIS\startup\startup_stm32f10x_md_vl.s
文件 15955 2011-03-10 10:51 stm32_cjson\CMSIS\startup\startup_stm32f10x_xl.s
文件 633941 2011-03-10 10:51 stm32_cjson\CMSIS\stm32f10x.h
文件 36557 2011-03-10 10:51 stm32_cjson\CMSIS\system_stm32f10x.c
文件 2085 2011-03-10 10:51 stm32_cjson\CMSIS\system_stm32f10x.h
目录 0 2012-07-22 11:07 stm32_cjson\FWlib\
目录 0 2012-07-22 11:07 stm32_cjson\FWlib\inc\
文件 8982 2011-03-10 10:47 stm32_cjson\FWlib\inc\misc.h
............此处省略65个文件信息
- 上一篇:物质扩散算法
- 下一篇:C++ primer plus 第六版 全部编程练习答案
相关资源
- 基于MFC的TCP调试助手源码95706
- 国际象棋的qt源代码
- 操作系统c语言模拟文件管理系统844
- C语言开发实战宝典
- C++中头文件与源文件的作用详解
- 基于mfc的多线程文件传输
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- C语言代码高亮html输出工具
- 猜数字游戏 c语言代码
- C语言课程设计
- 数字电位器C语言程序
- CCS FFT c语言算法
- 使用C语言编写的病房管理系统
- 通信过程中的RS编译码程序(c语言)
- 利用C++哈希表的方法实现电话号码查
- 计算机二级C语言上机填空,改错,编
- 用回溯法解决八皇后问题C语言实现
- 移木块游戏,可以自编自玩,vc6.0编写
- 简易教务管理系统c语言开发文档
- 操作系统课设 读写者问题 c语言实现
- 小波变换算法 c语言版
- C流程图生成器,用C语言代码 生成C语
- 3des加密算法C语言实现
- 简单的C语言点对点聊天程序
- 单片机c语言源程序(51定时器 八个按
- C++纯文字DOS超小RPG游戏
- 个人日常财务管理系统(C语言)
- MFC数字钟(基于VC6.0)
- c语言电子商务系统
评论
共有 条评论