15 Commits

Author SHA1 Message Date
liuyuxiu 3bc6c44998 tdd add
Signed-off-by: liuyuxiu <1175395694@qq.com>
2025-06-12 11:15:12 +08:00
liuyuxiu 07bbf94c1b revert bugfix
Signed-off-by: liuyuxiu <1175395694@qq.com>
2025-06-05 11:22:30 +08:00
liuyuxiu 7ef33e91c4 bugfix
Signed-off-by: liuyuxiu <1175395694@qq.com>
2025-05-20 18:14:39 +08:00
youbing54 63e50e3853 IssueNo: https://gitee.com/openharmony/third_party_cJSON/issues/IC7ESI
describe: 回退64位修改
Feature or Bugfix: Bugfix
Binary Source:Yes
Signed-off-by: youbing54<youbing3@huawei.com>
2025-05-13 14:30:05 +08:00
borne ac1e4b1368 feat: add int64 support
Offering: Open Source Institute

This commit adds int64 support for cjson. To enable int64, you need to define the macro ENABLE_INT64. To make it more clear, you need to build cjson like this if you are using makefile:

mkdir build
cd build
cmake -DENABLE_INT64=ON ..
make

This implementation changed the type of valueint in struct cJSON: from int to long long(int64), and added a new flag cJSON_IsInt64.
For a int64 cJSON item, the value of item->type would be cJSON_Number | cJSON_IsInt64.

The existing functions parse_number and print_number can handle int64 now.

Considering we have added a new type cJSON_IsInt64, some new functions have been added:
CJSON_PUBLIC(long long *) cJSON_GetInt64NumberValue(cJSON * const item)
CJSON_PUBLIC(cJSON_bool) cJSON_IsInt64Number(const cJSON * const item)
CJSON_PUBLIC(cJSON *) cJSON_CreateInt64Number(long long integer)
CJSON_PUBLIC(cJSON*) cJSON_AddInt64NumberToObject(cJSON * const object, const char * const name, const long long integer)
CJSON_PUBLIC(long long) cJSON_SetInt64NumberValue(cJSON * const object, const long long integer)

And some existing functions are also adjusted for int64, including parse_number, cJSON_SetNumberHelper, print_number, cJSON_CreateNumber, cJSON_Compare and compare_json(in cJSON_Utils).

Besides the code changes, we have also added some testcases for int64.
These tests will run if ENABLE_INT64 is turned on.

Ref:PeterAlfredLee
https://github.com/DaveGamble/cJSON/pull/689

Signed-off-by: borne <bo.lu@huawei.com>
2024-06-21 13:05:42 +08:00
mamingshuai a006830083 update openharmony 1.0.1 2021-03-11 20:34:23 +08:00
wenjun 2c251595b3 add OpenHarmony 1.0 baseline 2020-09-09 09:26:41 +08:00
Zach Hindes 4ddd0a8ffb Support default __stdcall calling convention on tests as well 2018-09-12 15:32:30 -05:00
Max Bruckner 949c083315 Move 'hooks' parameter into buffers (parse/print) 2017-04-27 02:48:28 +02:00
Max Bruckner e0d3a8a265 Limit nesting depth to 1000 and make it configurable. 2017-04-27 01:57:45 +02:00
Max Bruckner 87a204ed0b parse_functions: Return booleans instead of pointers 2017-04-08 17:56:26 +02:00
Max Bruckner f69b109c9f parse_number: Use parse_buffer 2017-04-08 17:56:25 +02:00
Max Bruckner c6e1a281f9 tests: assertion macros 2017-02-15 21:25:52 +01:00
Max Bruckner 4f58695ed3 tests: extract common functionality to common.c 2017-02-15 21:25:51 +01:00
Max Bruckner 7fd536d7e0 unity-tests: parse_number 2017-02-07 21:35:20 +01:00