-
Notifications
You must be signed in to change notification settings - Fork 270
Choice of JSON lib
Paul Philippov edited this page Sep 24, 2025
·
1 revision
Two the most popular JSON libraries for C are JSON-C and cJSON. The latter is smaller and preferable for embedded devices where every byte counts.
### Data Structure
json-c | cJSON | Notes
---------------------------------------------|--------------------------------------|-------
json_object * | cJSON * |
### Memory Management
json-c | cJSON | Notes
---------------------------------------------|--------------------------------------|-------
json_object_put(obj) | cJSON_Delete(obj) | Different memory management model
### Parsing Functions
json-c | cJSON | Notes
---------------------------------------------|--------------------------------------|-------
json_object_from_file(path) | cJSON_Parse(string) | cJSON requires manual file reading
### Object Access Functions
json-c | cJSON | Notes
---------------------------------------------|--------------------------------------|-------
json_object_object_get_ex(obj, key, &result) | cJSON_GetObjectItem(obj, key) | Different return pattern
### Type Checking Functions
json-c | cJSON | Notes
---------------------------------------------|--------------------------------------|-------
json_object_is_type(obj, json_type_string) | cJSON_IsString(obj) | More specific functions
json_object_is_type(obj, json_type_boolean) | cJSON_IsBool(obj) |
json_object_is_type(obj, json_type_int) | cJSON_IsNumber(obj) |
json_object_is_type(obj, json_type_double) | cJSON_IsNumber(obj) |
json_object_is_type(obj, json_type_object) | cJSON_IsObject(obj) |
json_object_is_type(obj, json_type_array) | cJSON_IsArray(obj) |
### Value Extraction Functions
json-c | cJSON | Notes
---------------------------------------------|--------------------------------------|-------
json_object_get_string(obj) | cJSON_GetStringValue(obj) |
json_object_get_boolean(obj) | cJSON_IsTrue(obj) | Returns boolean
json_object_get_int(obj) | cJSON_GetNumberValue(obj) | Returns double, cast needed
json_object_get_int64(obj) | cJSON_GetNumberValue(obj) | Returns double, cast needed
json_object_get_double(obj) | cJSON_GetNumberValue(obj) |
### Object Creation Functions
json-c | cJSON | Notes
---------------------------------------------|--------------------------------------|-------
json_object_new_object() | cJSON_CreateObject() |
json_object_new_string(str) | cJSON_CreateString(str) |
json_object_new_boolean(val) | cJSON_CreateBool(val) |
json_object_new_int(val) | cJSON_CreateNumber(val) |
json_object_new_int64(val) | cJSON_CreateNumber(val) |
json_object_new_double(val) | cJSON_CreateNumber(val) |
json_object_new_array() | cJSON_CreateArray() |
### Object Manipulation Functions
json-c | cJSON | Notes
---------------------------------------------|--------------------------------------|-------
json_object_object_add(obj, key, val) | cJSON_AddItemToObject(obj, key, val) |
json_object_array_add(arr, val) | cJSON_AddItemToArray(arr, val) |
json_object_object_del(obj, key) | cJSON_DeleteItemFromObject(obj, key) |
### Array Functions
json-c | cJSON | Notes
---------------------------------------------|--------------------------------------|-------
json_object_array_length(arr) | cJSON_GetArraySize(arr) |
json_object_array_get_idx(arr, idx) | cJSON_GetArrayItem(arr, idx) |
### Serialization Functions
json-c | cJSON | Notes
---------------------------------------------|--------------------------------------|-------
json_object_to_json_string_ext(obj, flags) | cJSON_Print(obj) | Always pretty prints
- Wiki Home
- About the Project
- Getting Started
-
Supported Cameras
- Cameras
- 360 AP1PA3
- AliExpress LTIA‐37FJZ (Vanhua Z55 module)
- AOQEE C1
- Aosu C5L
- Cinnado
- Dekco DC5L
- Eufy
- Galayou/Wansview
- Hualai (Wyze/Atom/Neos/Personal)
- iFlytek XFP301‐M
- Jienuo JN-107-AR-E-WIFI
- Jooan A6M
- LaView L2
- LongPlus X07
- LSC 3215672
- Sannce I21AG
- Sonoff Cam‐S2 and B1P
- TP-Link Tapo C100/C110/C111
- Wuuk Y0510
- Xiaomi
- Configuration
- Integration
- Development