当前位置:网站首页>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));
边栏推荐
- Nature | make an account of the new crown casualties in the world
- FPGA语法的细节
- Memory model, reference and function supplement of program
- Special materials | household appliances, white electricity, kitchen electricity
- log4j 1. X upgrade to 2 Solution of X dependency incompatibility
- Leetcode simple problem: converting an integer to the sum of two zero free integers
- yolov5
- Research Report on market supply and demand and strategy of China's digital camera lens industry
- Role and understanding of proc/cmdline
- Greenplum [question 05] Greenplum streaming server custom client problem handling (increasing)
猜你喜欢
![【长时间序列预测】Aotoformer 代码详解之[4]自相关机制](/img/12/27531fc791b3f49306385831309c5e.png)
【长时间序列预测】Aotoformer 代码详解之[4]自相关机制

Role and understanding of proc/cmdline

个体工商户是不是法人企业
![[long time series prediction] the [4] autocorrelation mechanism of aotoformer code explanation](/img/12/27531fc791b3f49306385831309c5e.png)
[long time series prediction] the [4] autocorrelation mechanism of aotoformer code explanation

Halcon 3D 1 读取3d数据

Rtmp/rtsp/hls public network real available test address

Towards End-to-End Lane Detection: an Instance SegmentationApproach

Conversion of Halcon 3D depth map to 3D image

基于tensorflow的校园绿植识别

公司注册认缴资金多久
随机推荐
How does WiFi 802.11 correspond to 802.3
Halcon uses points to fit a plane
RTMP streaming +rtmp playback low delay solution in unity environment
PHP实现图片登录验证码的解决方案
Makefile文件编写快速掌握
基于LFFD模型目标检测自动标注生成xml文件
Towards End-to-End Lane Detection: an Instance SegmentationApproach
Research Report on market supply and demand and strategy of China's digital camera lens industry
[fastapi] use pycharm to configure and use environment variables for fastapi projects
Redis persistence
Optipng can optimize the compressed PNG picture file format
Kubernetes certificate online update
深入理解异步编程
China embolic coil market trend report, technical innovation and market forecast
Greenplum [question 05] Greenplum streaming server custom client problem handling (increasing)
AddUser add user and mount hard disk
Why can't NAND flash be used as RAM while nor flash can
公司注册认缴资金多久
Codis 3. X expansion and contraction
WiFi band resources