diff --git a/src/json.c b/src/json.c index 1023367..aadc072 100644 --- a/src/json.c +++ b/src/json.c @@ -117,4 +117,36 @@ void print_json_keyvalue(const char *json_key, const char *json_value, int json_ free(safe_key); free(safe_value); -} \ No newline at end of file +} + +void print_json_nokeyvalue(const char *json_value, int json_first_record, int json_space) { + if (json_value == NULL) { + fprintf(stderr, "Error: NULL pointer provided\n"); + return; + } + + size_t value_len = strlen(json_value); + + char *safe_value = malloc(value_len + 1); + + if (safe_value == NULL) { + fprintf(stderr, "Error: Memory allocation failed\n"); + free(safe_value); + return; + } + + strcpy(safe_value, json_value); + + if (json_first_record == 0) + fprintf(stderr, ",\n"); + else + fprintf(stderr, "\n"); + + for (int i = 0; i < json_space; i++){ + fprintf(stderr, " "); + } + + fprintf(stderr, "\"%s\"", safe_value); + + free(safe_value); +}