@@ -82,8 +82,6 @@ make O=<编译输出目录> CROSS_COMPILE=<交叉编译器前缀> && make O=<编
82
82
83
83
## json对象结构
84
84
85
- 使用 long long 类型支持,编译时需要设置 json.h 中的 ` JSON_LONG_LONG_SUPPORT ` 值为 1
86
-
87
85
``` c
88
86
struct json_list {
89
87
struct json_list *next;
@@ -98,10 +96,8 @@ typedef enum {
98
96
JSON_BOOL,
99
97
JSON_INT,
100
98
JSON_HEX,
101
- #if JSON_LONG_LONG_SUPPORT
102
99
JSON_LINT,
103
100
JSON_LHEX,
104
- #endif
105
101
JSON_DOUBLE,
106
102
JSON_STRING,
107
103
JSON_ARRAY,
@@ -119,12 +115,10 @@ typedef struct {
119
115
120
116
typedef union {
121
117
bool vbool;
122
- int vint;
123
- unsigned int vhex;
124
- #if JSON_LONG_LONG_SUPPORT
125
- long long int vlint;
126
- unsigned long long int vlhex;
127
- #endif
118
+ int32_t vint;
119
+ uint32_t vhex;
120
+ int64_t vlint;
121
+ uint64_t vlhex;
128
122
double vdbl;
129
123
} json_number_t ; // json数字对象值
130
124
@@ -187,24 +181,20 @@ json_object *json_create_item_array(json_type_t type, void *values, int count);
187
181
188
182
static inline json_object * json_create_null(void);
189
183
static inline json_object * json_create_bool(bool value);
190
- static inline json_object * json_create_int(int value);
191
- static inline json_object * json_create_hex(unsigned int value);
192
- #if JSON_LONG_LONG_SUPPORT
193
- static inline json_object * json_create_lint(long long int value);
194
- static inline json_object * json_create_lhex(unsigned long long int value);
195
- #endif
184
+ static inline json_object * json_create_int(int32_t value);
185
+ static inline json_object * json_create_hex(uint32_t value);
186
+ static inline json_object * json_create_lint(int64_t value);
187
+ static inline json_object * json_create_lhex(uint64_t value);
196
188
static inline json_object * json_create_double(double value);
197
189
static inline json_object * json_create_string(json_string_t * value);
198
190
static inline json_object * json_create_array(void);
199
191
static inline json_object * json_create_object(void);
200
192
201
193
static inline json_object * json_create_bool_array(bool * values, int count);
202
- static inline json_object * json_create_int_array(int * values, int count);
203
- static inline json_object * json_create_hex_array(unsigned int * values, int count);
204
- #if JSON_LONG_LONG_SUPPORT
205
- static inline json_object * json_create_lint_array(long long int * values, int count);
206
- static inline json_object * json_create_lhex_array(unsigned long long int * values, int count);
207
- #endif
194
+ static inline json_object * json_create_int_array(int32_t * values, int count);
195
+ static inline json_object * json_create_hex_array(uint32_t * values, int count);
196
+ static inline json_object * json_create_lint_array(int64_t * values, int count);
197
+ static inline json_object * json_create_lhex_array(uint64_t * values, int count);
208
198
static inline json_object * json_create_double_array(double * values, int count);
209
199
static inline json_object * json_create_string_array(json_string_t * values, int count);
210
200
```
@@ -234,21 +224,17 @@ int json_get_number_value(json_object *json, json_type_t type, void *value);
234
224
int json_set_number_value(json_object * json, json_type_t type, void * value);
235
225
236
226
static inline bool json_get_bool_value(json_object * json);
237
- static inline int json_get_int_value(json_object * json);
238
- static inline unsigned int json_get_hex_value(json_object * json);
239
- #if JSON_LONG_LONG_SUPPORT
240
- static inline long long int json_get_lint_value(json_object * json);
241
- static inline unsigned long long int json_get_lhex_value(json_object * json);
242
- #endif
227
+ static inline int32_t json_get_int_value(json_object * json);
228
+ static inline uint32_t json_get_hex_value(json_object * json);
229
+ static inline int64_t json_get_lint_value(json_object * json);
230
+ static inline uint64_t json_get_lhex_value(json_object * json);
243
231
static inline double json_get_double_value(json_object * json);
244
232
245
233
static inline int json_set_bool_value(json_object * json, bool value);
246
- static inline int json_set_int_value(json_object * json, int value);
247
- static inline int json_set_hex_value(json_object * json, unsigned int value);
248
- #if JSON_LONG_LONG_SUPPORT
249
- static inline int json_set_lint_value(json_object * json, long long int value);
250
- static inline int json_set_lhex_value(json_object * json, unsigned long long int value);
251
- #endif
234
+ static inline int json_set_int_value(json_object * json, int32_t value);
235
+ static inline int json_set_hex_value(json_object * json, uint32_t value);
236
+ static inline int json_set_lint_value(json_object * json, int64_t value);
237
+ static inline int json_set_lhex_value(json_object * json, uint64_t value);
252
238
static inline int json_set_double_value(json_object * json, double value);
253
239
```
254
240
@@ -326,25 +312,21 @@ json_object *json_add_new_item_to_object(json_object *object, json_type_t type,
326
312
327
313
static inline json_object * json_add_null_to_array(json_object * array);
328
314
static inline json_object * json_add_bool_to_array(json_object * array, bool value);
329
- static inline json_object * json_add_int_to_array(json_object * array, int value);
330
- static inline json_object * json_add_hex_to_array(json_object * array, unsigned int value);
331
- #if JSON_LONG_LONG_SUPPORT
332
- static inline json_object * json_add_lint_to_array(json_object * array, long long int value);
333
- static inline json_object * json_add_lhex_to_array(json_object * array, unsigned long long int value);
334
- #endif
315
+ static inline json_object * json_add_int_to_array(json_object * array, int32_t value);
316
+ static inline json_object * json_add_hex_to_array(json_object * array, uint32_t value);
317
+ static inline json_object * json_add_lint_to_array(json_object * array, int64_t value);
318
+ static inline json_object * json_add_lhex_to_array(json_object * array, uint64_t value);
335
319
static inline json_object * json_add_double_to_array(json_object * array, double value);
336
320
static inline json_object * json_add_string_to_array(json_object * array, json_string_t * value);
337
321
static inline json_object * json_add_array_to_array(json_object * array);
338
322
static inline json_object * json_add_object_to_array(json_object * array);
339
323
340
324
static inline json_object * json_add_null_to_object(json_object * object, json_string_t * jkey);
341
325
static inline json_object * json_add_bool_to_object(json_object * object, json_string_t * jkey, bool value);
342
- static inline json_object * json_add_int_to_object(json_object * object, json_string_t * jkey, int value);
343
- static inline json_object * json_add_hex_to_object(json_object * object, json_string_t * jkey, unsigned int value);
344
- #if JSON_LONG_LONG_SUPPORT
345
- static inline json_object * json_add_lint_to_object(json_object * object, json_string_t * jkey, long long int value);
346
- static inline json_object * json_add_lhex_to_object(json_object * object, json_string_t * jkey, unsigned long long int value);
347
- #endif
326
+ static inline json_object * json_add_int_to_object(json_object * object, json_string_t * jkey, int32_t value);
327
+ static inline json_object * json_add_hex_to_object(json_object * object, json_string_t * jkey, uint32_t value);
328
+ static inline json_object * json_add_lint_to_object(json_object * object, json_string_t * jkey, int64_t value);
329
+ static inline json_object * json_add_lhex_to_object(json_object * object, json_string_t * jkey, uint64_t value);
348
330
static inline json_object * json_add_double_to_object(json_object * object, json_string_t * jkey, double value);
349
331
static inline json_object * json_add_string_to_object(json_object * object, json_string_t * jkey, json_string_t * value);
350
332
static inline json_object * json_add_array_to_object(json_object * object, json_string_t * jkey);
@@ -426,24 +408,20 @@ json_object *pjson_create_item_array(json_type_t item_type, void *values, int co
426
408
427
409
static inline json_object *pjson_create_null(json_mem_t *mem);
428
410
static inline json_object *pjson_create_bool(bool value, json_mem_t *mem);
429
- static inline json_object *pjson_create_int(int value, json_mem_t *mem);
430
- static inline json_object *pjson_create_hex(unsigned int value, json_mem_t *mem);
431
- #if JSON_LONG_LONG_SUPPORT
432
- static inline json_object *pjson_create_lint(long long int value, json_mem_t *mem);
433
- static inline json_object *pjson_create_lhex(unsigned long long int value, json_mem_t *mem);
434
- #endif
411
+ static inline json_object *pjson_create_int(int32_t value, json_mem_t *mem);
412
+ static inline json_object *pjson_create_hex(uint32_t value, json_mem_t *mem);
413
+ static inline json_object *pjson_create_lint(int64_t value, json_mem_t *mem);
414
+ static inline json_object *pjson_create_lhex(uint64_t value, json_mem_t *mem);
435
415
static inline json_object *pjson_create_double(double value, json_mem_t *mem);
436
416
static inline json_object *pjson_create_string(json_string_t *value, json_mem_t *mem);
437
417
static inline json_object *pjson_create_array(json_mem_t *mem);
438
418
static inline json_object *pjson_create_object(json_mem_t *mem);
439
419
440
420
static inline json_object *pjson_create_bool_array(bool *values, int count, json_mem_t *mem);
441
- static inline json_object *pjson_create_int_array(int *values, int count, json_mem_t *mem);
442
- static inline json_object *pjson_create_hex_array(unsigned int *values, int count, json_mem_t *mem);
443
- #if JSON_LONG_LONG_SUPPORT
444
- static inline json_object *pjson_create_lint_array(long long int *values, int count, json_mem_t *mem);
445
- static inline json_object *pjson_create_lhex_array(unsigned long long int *values, int count, json_mem_t *mem);
446
- #endif
421
+ static inline json_object *pjson_create_int_array(int32_t *values, int count, json_mem_t *mem);
422
+ static inline json_object *pjson_create_hex_array(uint32_t *values, int count, json_mem_t *mem);
423
+ static inline json_object *pjson_create_lint_array(int64_t *values, int count, json_mem_t *mem);
424
+ static inline json_object *pjson_create_lhex_array(uint64_t *values, int count, json_mem_t *mem);
447
425
static inline json_object *pjson_create_double_array(double *values, int count, json_mem_t *mem);
448
426
static inline json_object *pjson_create_string_array(json_string_t *values, int count, json_mem_t *mem);
449
427
```
@@ -485,25 +463,21 @@ json_object *pjson_add_new_item_to_object(json_object *object, json_type_t type,
485
463
486
464
static inline json_object *pjson_add_null_to_array(json_object *array, json_mem_t *mem);
487
465
static inline json_object *pjson_add_bool_to_array(json_object *array, bool value, json_mem_t *mem);
488
- static inline json_object *pjson_add_int_to_array(json_object *array, int value, json_mem_t *mem);
489
- static inline json_object *pjson_add_hex_to_array(json_object *array, unsigned int value, json_mem_t *mem);
490
- #if JSON_LONG_LONG_SUPPORT
491
- static inline json_object *pjson_add_lint_to_array(json_object *array, long long int value, json_mem_t *mem);
492
- static inline json_object *pjson_add_lhex_to_array(json_object *array, unsigned long long int value, json_mem_t *mem);
493
- #endif
466
+ static inline json_object *pjson_add_int_to_array(json_object *array, int32_t value, json_mem_t *mem);
467
+ static inline json_object *pjson_add_hex_to_array(json_object *array, uint32_t value, json_mem_t *mem);
468
+ static inline json_object *pjson_add_lint_to_array(json_object *array, int64_t value, json_mem_t *mem);
469
+ static inline json_object *pjson_add_lhex_to_array(json_object *array, uint64_t value, json_mem_t *mem);
494
470
static inline json_object *pjson_add_double_to_array(json_object *array, double value, json_mem_t *mem);
495
471
static inline json_object *pjson_add_string_to_array(json_object *array, json_string_t *value, json_mem_t *mem);
496
472
static inline json_object *pjson_add_array_to_array(json_object *array, json_mem_t *mem);
497
473
static inline json_object *pjson_add_object_to_array(json_object *array, json_mem_t *mem);
498
474
499
475
static inline json_object *pjson_add_null_to_object(json_object *object, json_string_t *jkey, json_mem_t *mem);
500
476
static inline json_object *pjson_add_bool_to_object(json_object *object, json_string_t *jkey, bool value, json_mem_t *mem);
501
- static inline json_object *pjson_add_int_to_object(json_object *object, json_string_t *jkey, int value, json_mem_t *mem);
502
- static inline json_object *pjson_add_hex_to_object(json_object *object, json_string_t *jkey, unsigned int value, json_mem_t *mem);
503
- #if JSON_LONG_LONG_SUPPORT
504
- static inline json_object *pjson_add_lint_to_object(json_object *object, json_string_t *jkey, long long int value, json_mem_t *mem);
505
- static inline json_object *pjson_add_lhex_to_object(json_object *object, json_string_t *jkey, unsigned long long int value, json_mem_t *mem);
506
- #endif
477
+ static inline json_object *pjson_add_int_to_object(json_object *object, json_string_t *jkey, int32_t value, json_mem_t *mem);
478
+ static inline json_object *pjson_add_hex_to_object(json_object *object, json_string_t *jkey, uint32_t value, json_mem_t *mem);
479
+ static inline json_object *pjson_add_lint_to_object(json_object *object, json_string_t *jkey, int64_t value, json_mem_t *mem);
480
+ static inline json_object *pjson_add_lhex_to_object(json_object *object, json_string_t *jkey, uint64_t value, json_mem_t *mem);
507
481
static inline json_object *pjson_add_double_to_object(json_object *object, json_string_t *jkey, double value, json_mem_t *mem);
508
482
static inline json_object *pjson_add_string_to_object(json_object *object, json_string_t *jkey, json_string_t *value, json_mem_t *mem);
509
483
static inline json_object *pjson_add_array_to_object(json_object *object, json_string_t *jkey, json_mem_t *mem);
@@ -606,12 +580,10 @@ static inline json_sax_print_hd json_sax_fprint_unformat_start(int item_total, c
606
580
int json_sax_print_value(json_sax_print_hd handle, json_type_t type, json_string_t *jkey, const void *value);
607
581
static inline int json_sax_print_null(json_sax_print_hd handle, json_string_t *jkey);
608
582
static inline int json_sax_print_bool(json_sax_print_hd handle, json_string_t *jkey, bool value);
609
- static inline int json_sax_print_int(json_sax_print_hd handle, json_string_t *jkey, int value);
610
- static inline int json_sax_print_hex(json_sax_print_hd handle, json_string_t *jkey, unsigned int value);
611
- #if JSON_LONG_LONG_SUPPORT
612
- static inline int json_sax_print_lint(json_sax_print_hd handle, json_string_t *jkey, long long int value);
613
- static inline int json_sax_print_lhex(json_sax_print_hd handle, json_string_t *jkey, unsigned long long int value);
614
- #endif
583
+ static inline int json_sax_print_int(json_sax_print_hd handle, json_string_t *jkey, int32_t value);
584
+ static inline int json_sax_print_hex(json_sax_print_hd handle, json_string_t *jkey, uint32_t value);
585
+ static inline int json_sax_print_lint(json_sax_print_hd handle, json_string_t *jkey, int64_t value);
586
+ static inline int json_sax_print_lhex(json_sax_print_hd handle, json_string_t *jkey, uint64_t value);
615
587
static inline int json_sax_print_double(json_sax_print_hd handle, json_string_t *jkey, double value);
616
588
static inline int json_sax_print_string(json_sax_print_hd handle, json_string_t *jkey, json_string_t *value);
617
589
static inline int json_sax_print_array(json_sax_print_hd handle, json_string_t *jkey, json_sax_cmd_t value);
0 commit comments