当前位置:网站首页>Json-c common APIs
Json-c common APIs
2022-06-12 05:46:00 【LEO-max】
What is? Json
Json(JavaScript Object Notation,JS Object shorthand ) Is a lightweight data exchange format . Easy to read and write . At the same time, it is also easy for machine analysis and generation .
Some legal Json example :
Key value pair :( You can have no keys, only values )
key value
↓ ↓
1. {
"name": "Leo", "sex": "male"}
2. {
"name": "Jack", "age": 18, "address": {
"country": "china", "zip-code": "10000"}}
3. {
"a": "1", "b": [1,2,3]}
Json-c API
json_object Support type :
/* supported object types */
typedef enum json_type {
/* If you change this, be sure to update json_type_to_name() too */
json_type_null,
json_type_boolean,
json_type_double,
json_type_int,
json_type_object,
json_type_array,
json_type_string
} json_type;
Will conform to Json The format string is constructed as a Json object
struct json_object * json_tokener_parse(const char *s);take Json Object content is converted to Json Format string
const char *json_object_to_json_string(struct json_object *obj);establish Json object
struct json_object *json_object_new_object();Go to Json Object
void json_object_object_add(struct json_object *obj, const char *key, struct json_object *value);take C String conversion to Json Object in string format
struct json_object* json_object_new_string(const char *s);Converts an integer value to Json Formatted objects
struct json_object* json_object_new_int(int a);obtain Json The integer value of the object
int32 json_object_get_int(struct json_object *obj);obtain Json The string value of the object
const char *json_object_get_string(struct json_object *obj); analysis Json Divided into two steps :
First step : By key name , from Json Object to get the corresponding data Json object
struct json_object *json; json_object_object_get_ex(obj, "name", &json); The second step : According to the type of data , Set the data to the corresponding Json Object to the corresponding type of data
json_type type = json_object_get_type(json); if(json_type_string == type){ printf("name: %s\n". json_object_get_string(json)); //json Object to string type } // Allied json_object_object_get_ex(obj, "age", &json); printf("age: %d\n", json_object_get_int(json)); json_object_object_get_ex(obj, "sex", &json); printf("sex: %s\n", json_object_get_string(json));
边栏推荐
- 论文阅读_图神经网络GIN
- RTMP streaming +rtmp playback low delay solution in unity environment
- XML parameter schema, the same MTK SW version is compatible with two different sets of audio parameters
- 公司注册认缴资金多久
- Introduction to redis high availability
- March 4, 2021
- Halcon 3D 1 Reading 3D data
- CODIS stress test (PHP)
- Laravel8 authentication login
- Redis cluster cluster capacity expansion and data migration
猜你喜欢

POI, easyexcel framework use

Introduction to Internet Protocol

Tabulation skills and matrix processing skills

CCF noi2022 quota allocation scheme

Halcon 用点来拟合平面

Word frequency statistics using Jieba database

深入理解异步编程

Execute sh script to prompt "[[: not found" solution. The difference between Bash and sh

WiFi protocol and ieee905 protocol learning details

Heap classical problem
随机推荐
beginning一款非常优秀的emlog主题v3.1,支持Emlog Pro
Niuke daily question -day1
Flex/fixed upper, middle and lower (mobile end)
Available RTMP and RTSP test addresses of the public network (updated in March, 2021)
yolov5
Halcon 3D 1 读取3d数据
What is the lszrz protocol used at ordinary times? Talk about xmodem/ymodem/zmodem
个人申请OV类型SSL证书
将一个文件夹图片分成训练集和测试集
38. 外观数列
【js小知识】轻松了解js防抖与节流
nrf52832--官方例程ble_app_uart添加led特性,实现电脑uart和手机app控制开发板led开和关
Stack and queue classic interview questions
Thesis reading_ Figure neural network gin
Lock and reentrankload
Chapter 7 - pointer learning
jpg格式与xml格式文件分离到不同的文件夹
DMA RDMA technology details
Chapter 8 - structure
POI, easyexcel framework use