rsstats 0.0.1
Redis Enterprise Statistic collector
json.c File Reference

Wrapper around cJSON library with helpers. More...

#include "json.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for json.c:

Go to the source code of this file.

Functions

char * json2text (cJSON *value_json)
 Convert a cJSON object in a C String. More...
 

Detailed Description

Wrapper around cJSON library with helpers.

This library is only a simple wrapper around the cJSON library, providing helper functions.

Author
François Cerbelle (Fanfan), franc.nosp@m.ois@.nosp@m.cerbe.nosp@m.lle..nosp@m.net

Definition in file json.c.

Function Documentation

◆ json2text()

char * json2text ( cJSON value_json)

Convert a cJSON object in a C String.

Parameters
value_jsonthe cJSON value to convert
Returns
The C string conversion dynamically allocated.
Return values
NULLif there was a problem, such as an Out Of Memory
Pointerto a zero terminated C string.

It converts NULL values, String values, Integer values, Boolean values in C strings. If the value is an array, it is fully pretty printed. If the JSON value is nothing in this list, the function returns the "Invalid data" string.

The returned strings are allocated using malloc on the heap and should be freed by the calling application.

Definition at line 31 of file json.c.