Skip to content

feat: add cJSON_GetAllKeys to extract all keys from an object - #1059

Open
quan35 wants to merge 1 commit into
DaveGamble:masterfrom
quan35:master
Open

feat: add cJSON_GetAllKeys to extract all keys from an object#1059
quan35 wants to merge 1 commit into
DaveGamble:masterfrom
quan35:master

Conversation

@quan35

@quan35 quan35 commented Jul 29, 2026

Copy link
Copy Markdown

Add a new public API function cJSON_GetAllKeys that returns all top-level keys of a JSON object as a cJSON string array.

Usage:
cJSON *obj = cJSON_Parse("{"name":"Alice","age":30}");
cJSON *keys = cJSON_GetAllKeys(obj);
// keys is now ["name", "age"]
cJSON_Delete(keys);
cJSON_Delete(obj);

Behavior:

  • Returns a cJSON array of cJSON strings, in insertion order
  • Returns NULL if passed NULL or a non-Object type
  • Returns an empty array for an empty object
  • Caller is responsible for freeing the result with cJSON_Delete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant