xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 1.58KB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發布日期: 2024-04-19
  • 語言: C/C++
  • 標簽: json??js??

資源簡介

json讀取(json.c)

資源截圖

代碼片段和文件信息

#include?
#include?“cJSON.h“
#include?
#include?
#include?
#include?
#include?“sys/shm.h“?

?int?ReadJson()?
{??
//打開保存JSON數據的文件?
int?fd?=?open(“data.json“O_RDWR);
if(fd? perror(“open?fail\n“);
return?-1;
}
//讀取文件中的數據?
char?buf[2048]?=?{0};
int?ret?=?read(fd?buf?sizeof(buf));
if(ret?==?-1){
perror(“read?error“);
return?-1;?
}
//關閉文件?
close(fd);
//把該字符串數據轉換成JSON數據??(對象)
cJSON?*root=cJSON_Parse(buf);
if(root?==?NULL){
printf(“parse?error\n“);
return?-1;?
}
//獲取數組對象?
//當前的value?是一個數組對象
cJSON?*value?=?cJSON_GetobjectItem(root“cam_list“);
if(value?==?NULL){
printf(“GetobjectItem?error\n“);
return?-1;
}
//獲取該數組對象的大小
int?len?

評論

共有 條評論