int test(void)
{
	char str[] = "{\"test\":null}";
	printf("str:%s\n", str);
	
	cJSON *json = cJSON_Parse(str);
	if (json == NULL)
	{
		printf("json NULL\n");
		return -1;
	}

	cJSON *test =  cJSON_GetObjectItem(json, "test");
	if (test->type == cJSON_NULL) //判断类型
	{
		printf("type : cJSON_NULL\n");
	}
	// printf("%d\n", test->valueint); //打印 0
	// printf("%s\n", test->valuestring); //段错误
	// printf("%ld\n", strlen(test->valuestring)); //段错误
}

GitHub 加速计划 / cj / cJSON
13
4
下载
Ultralightweight JSON parser in ANSI C
最近提交(Master分支:20 天前 )
c859b25d 18 天前
74e1ff49 this fixes CVE-2025-57052 23 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐