I am facing undefined reference issue in vs code when I run program with cJSON.h file.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cJSON.h"
int main() {
const char *json_string = "JSON STRING":
cJSON *json = cJSON_Parse(json_string);
if (json != NULL) {
cJSON *rootObject = json; // The root object of the parsed JSON
cJSON *currentItem = rootObject->child; // Start traversing from the first element
while (currentItem != NULL) {
if (currentItem->type == cJSON_Object) {
printf("Key: %s is an object.\n", currentItem->string);
// Perform operations specific to an object here
}
currentItem = currentItem->next; // Move to the next element
}
cJSON_Delete(json); // Clean up cJSON object
} else {
printf("Failed to parse JSON.\n");
}
return 0;
}
But still I am facing the issue.