FreeRDP
Loading...
Searching...
No Matches
json.h
1
21#ifndef WINPR_UTILS_JSON
22#define WINPR_UTILS_JSON
23
24#include <winpr/winpr.h>
25#include <winpr/string.h>
26#include <winpr/wtypes.h>
27
34#ifdef __cplusplus
35extern "C"
36{
37#endif
38
39 typedef void WINPR_JSON;
40
49 WINPR_API int WINPR_JSON_version(char* buffer, size_t len);
50
57 WINPR_API void WINPR_JSON_Delete(WINPR_JSON* item);
58
66 WINPR_ATTR_MALLOC(WINPR_JSON_Delete, 1)
67 WINPR_API WINPR_JSON* WINPR_JSON_Parse(const char* value);
68
77 WINPR_ATTR_MALLOC(WINPR_JSON_Delete, 1)
78 WINPR_API WINPR_JSON* WINPR_JSON_ParseWithLength(const char* value, size_t buffer_length);
79
87 WINPR_ATTR_MALLOC(WINPR_JSON_Delete, 1)
88 WINPR_API WINPR_JSON* WINPR_JSON_ParseFromFile(const char* filename);
89
97 WINPR_ATTR_MALLOC(WINPR_JSON_Delete, 1)
98 WINPR_API WINPR_JSON* WINPR_JSON_ParseFromFileFP(FILE* fp);
99
107 WINPR_API size_t WINPR_JSON_GetArraySize(const WINPR_JSON* array);
108
117 WINPR_API WINPR_JSON* WINPR_JSON_GetArrayItem(const WINPR_JSON* array, size_t index);
118
126 WINPR_API WINPR_JSON* WINPR_JSON_GetObjectItem(const WINPR_JSON* object, const char* string);
127
136 WINPR_API WINPR_JSON* WINPR_JSON_GetObjectItemCaseSensitive(const WINPR_JSON* object,
137 const char* string);
138
146 WINPR_API BOOL WINPR_JSON_HasObjectItem(const WINPR_JSON* object, const char* string);
147
153 WINPR_API const char* WINPR_JSON_GetErrorPtr(void);
154
161 WINPR_API const char* WINPR_JSON_GetStringValue(WINPR_JSON* item);
162
169 WINPR_API double WINPR_JSON_GetNumberValue(const WINPR_JSON* item);
170
177 WINPR_API BOOL WINPR_JSON_IsInvalid(const WINPR_JSON* item);
178
185 WINPR_API BOOL WINPR_JSON_IsFalse(const WINPR_JSON* item);
186
193 WINPR_API BOOL WINPR_JSON_IsTrue(const WINPR_JSON* item);
194
201 WINPR_API BOOL WINPR_JSON_IsBool(const WINPR_JSON* item);
202
209 WINPR_API BOOL WINPR_JSON_IsNull(const WINPR_JSON* item);
210
217 WINPR_API BOOL WINPR_JSON_IsNumber(const WINPR_JSON* item);
218
225 WINPR_API BOOL WINPR_JSON_IsString(const WINPR_JSON* item);
226
233 WINPR_API BOOL WINPR_JSON_IsArray(const WINPR_JSON* item);
234
241 WINPR_API BOOL WINPR_JSON_IsObject(const WINPR_JSON* item);
242
248 WINPR_API WINPR_JSON* WINPR_JSON_CreateNull(void);
249
255 WINPR_API WINPR_JSON* WINPR_JSON_CreateTrue(void);
256
262 WINPR_API WINPR_JSON* WINPR_JSON_CreateFalse(void);
263
270 WINPR_API WINPR_JSON* WINPR_JSON_CreateBool(BOOL boolean);
271
278 WINPR_API WINPR_JSON* WINPR_JSON_CreateNumber(double num);
279
286 WINPR_API WINPR_JSON* WINPR_JSON_CreateString(const char* string);
287
293 WINPR_API WINPR_JSON* WINPR_JSON_CreateArray(void);
294
300 WINPR_API WINPR_JSON* WINPR_JSON_CreateObject(void);
301
309 WINPR_API WINPR_JSON* WINPR_JSON_AddNullToObject(WINPR_JSON* object, const char* name);
310
318 WINPR_API WINPR_JSON* WINPR_JSON_AddTrueToObject(WINPR_JSON* object, const char* name);
319
327 WINPR_API WINPR_JSON* WINPR_JSON_AddFalseToObject(WINPR_JSON* object, const char* name);
328
336 WINPR_API WINPR_JSON* WINPR_JSON_AddBoolToObject(WINPR_JSON* object, const char* name,
337 BOOL boolean);
338
346 WINPR_API WINPR_JSON* WINPR_JSON_AddNumberToObject(WINPR_JSON* object, const char* name,
347 double number);
348
356 WINPR_API WINPR_JSON* WINPR_JSON_AddStringToObject(WINPR_JSON* object, const char* name,
357 const char* string);
358
366 WINPR_API WINPR_JSON* WINPR_JSON_AddObjectToObject(WINPR_JSON* object, const char* name);
367
375 WINPR_API WINPR_JSON* WINPR_JSON_AddArrayToObject(WINPR_JSON* object, const char* name);
376
384 WINPR_API BOOL WINPR_JSON_AddItemToArray(WINPR_JSON* array, WINPR_JSON* item);
385
394 WINPR_API char* WINPR_JSON_Print(WINPR_JSON* item);
395
404 WINPR_API char* WINPR_JSON_PrintUnformatted(WINPR_JSON* item);
405
406#ifdef __cplusplus
407}
408#endif
409
412#endif
WINPR_API WINPR_JSON * WINPR_JSON_CreateBool(BOOL boolean)
WINPR_JSON_CreateBool.
Definition json.c:418
WINPR_API WINPR_JSON * WINPR_JSON_CreateString(const char *string)
WINPR_JSON_CreateString.
Definition json.c:442
WINPR_API BOOL WINPR_JSON_HasObjectItem(const WINPR_JSON *object, const char *string)
Check if JSON has an object matching the name.
Definition json.c:210
WINPR_API WINPR_JSON * WINPR_JSON_AddNumberToObject(WINPR_JSON *object, const char *name, double number)
WINPR_JSON_AddNumberToObject.
Definition json.c:553
WINPR_API WINPR_JSON * WINPR_JSON_ParseFromFileFP(FILE *fp)
Parse a JSON string read from a FILE.
Definition json.c:694
WINPR_API BOOL WINPR_JSON_IsNull(const WINPR_JSON *item)
Check if JSON item is Null.
Definition json.c:324
WINPR_API WINPR_JSON * WINPR_JSON_GetObjectItem(const WINPR_JSON *object, const char *string)
Return a pointer to an JSON object item.
Definition json.c:184
WINPR_API BOOL WINPR_JSON_IsString(const WINPR_JSON *item)
Check if JSON item is of type String.
Definition json.c:349
WINPR_API BOOL WINPR_JSON_AddItemToArray(WINPR_JSON *array, WINPR_JSON *item)
Add an item to an existing array.
Definition json.c:612
WINPR_API WINPR_JSON * WINPR_JSON_AddArrayToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddArrayToObject.
Definition json.c:635
WINPR_API BOOL WINPR_JSON_IsBool(const WINPR_JSON *item)
Check if JSON item is of type BOOL.
Definition json.c:312
WINPR_API double WINPR_JSON_GetNumberValue(const WINPR_JSON *item)
Return the Number value of a JSON item.
Definition json.c:246
WINPR_API WINPR_JSON * WINPR_JSON_AddTrueToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddTrueToObject.
Definition json.c:495
WINPR_API WINPR_JSON * WINPR_JSON_CreateObject(void)
WINPR_JSON_CreateObject.
Definition json.c:465
WINPR_API WINPR_JSON * WINPR_JSON_CreateArray(void)
WINPR_JSON_CreateArray.
Definition json.c:454
WINPR_API int WINPR_JSON_version(char *buffer, size_t len)
Get the library version string.
Definition json.c:101
WINPR_API char * WINPR_JSON_Print(WINPR_JSON *item)
Serialize a JSON instance to string for minimal size without formatting see WINPR_JSON_PrintUnformatt...
Definition json.c:654
WINPR_API WINPR_JSON * WINPR_JSON_AddFalseToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddFalseToObject.
Definition json.c:514
WINPR_API WINPR_JSON * WINPR_JSON_ParseFromFile(const char *filename)
Parse a JSON string read from a file filename.
Definition json.c:684
WINPR_API BOOL WINPR_JSON_IsNumber(const WINPR_JSON *item)
Check if JSON item is of type Number.
Definition json.c:336
WINPR_API WINPR_JSON * WINPR_JSON_GetArrayItem(const WINPR_JSON *array, size_t index)
Return a pointer to an item in the array.
Definition json.c:155
WINPR_API WINPR_JSON * WINPR_JSON_GetObjectItemCaseSensitive(const WINPR_JSON *object, const char *string)
Same as WINPR_JSON_GetObjectItem but with case insensitive matching.
Definition json.c:197
WINPR_API WINPR_JSON * WINPR_JSON_AddStringToObject(WINPR_JSON *object, const char *name, const char *string)
WINPR_JSON_AddStringToObject.
Definition json.c:573
WINPR_API WINPR_JSON * WINPR_JSON_ParseWithLength(const char *value, size_t buffer_length)
Parse a JSON string.
Definition json.c:125
WINPR_API WINPR_JSON * WINPR_JSON_CreateFalse(void)
WINPR_JSON_CreateFalse.
Definition json.c:407
WINPR_API WINPR_JSON * WINPR_JSON_CreateNumber(double num)
WINPR_JSON_CreateNumber.
Definition json.c:430
WINPR_API BOOL WINPR_JSON_IsObject(const WINPR_JSON *item)
Check if JSON item is of type Object.
Definition json.c:373
WINPR_API WINPR_JSON * WINPR_JSON_AddBoolToObject(WINPR_JSON *object, const char *name, BOOL boolean)
WINPR_JSON_AddBoolToObject.
Definition json.c:533
WINPR_API BOOL WINPR_JSON_IsInvalid(const WINPR_JSON *item)
Check if JSON item is valid.
Definition json.c:258
WINPR_API char * WINPR_JSON_PrintUnformatted(WINPR_JSON *item)
Serialize a JSON instance to string without formatting for human readable formatted output see WINPR_...
Definition json.c:669
WINPR_API WINPR_JSON * WINPR_JSON_CreateNull(void)
WINPR_JSON_CreateNull.
Definition json.c:385
WINPR_API const char * WINPR_JSON_GetStringValue(WINPR_JSON *item)
Return the String value of a JSON item.
Definition json.c:234
WINPR_API WINPR_JSON * WINPR_JSON_AddNullToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddNullToObject.
Definition json.c:476
WINPR_API WINPR_JSON * WINPR_JSON_CreateTrue(void)
WINPR_JSON_CreateTrue.
Definition json.c:396
WINPR_API BOOL WINPR_JSON_IsFalse(const WINPR_JSON *item)
Check if JSON item is BOOL value False.
Definition json.c:282
WINPR_API void WINPR_JSON_Delete(WINPR_JSON *item)
Delete a WinPR JSON wrapper object.
Definition json.c:144
WINPR_API size_t WINPR_JSON_GetArraySize(const WINPR_JSON *array)
Get the number of arrayitems from an array.
Definition json.c:169
WINPR_API BOOL WINPR_JSON_IsArray(const WINPR_JSON *item)
Check if JSON item is of type Array.
Definition json.c:361
WINPR_API const char * WINPR_JSON_GetErrorPtr(void)
Return an error string.
Definition json.c:223
WINPR_API WINPR_JSON * WINPR_JSON_AddObjectToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddObjectToObject.
Definition json.c:593
WINPR_API WINPR_JSON * WINPR_JSON_Parse(const char *value)
Parse a '\0' terminated JSON string.
Definition json.c:113
WINPR_API BOOL WINPR_JSON_IsTrue(const WINPR_JSON *item)
Check if JSON item is BOOL value True.
Definition json.c:297