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_ATTR_NODISCARD
68 WINPR_API WINPR_JSON* WINPR_JSON_Parse(const char* value);
69
78 WINPR_ATTR_MALLOC(WINPR_JSON_Delete, 1)
79 WINPR_ATTR_NODISCARD
80 WINPR_API WINPR_JSON* WINPR_JSON_ParseWithLength(const char* value, size_t buffer_length);
81
89 WINPR_ATTR_MALLOC(WINPR_JSON_Delete, 1)
90 WINPR_ATTR_NODISCARD
91 WINPR_API WINPR_JSON* WINPR_JSON_ParseFromFile(const char* filename);
92
100 WINPR_ATTR_MALLOC(WINPR_JSON_Delete, 1)
101 WINPR_ATTR_NODISCARD
102 WINPR_API WINPR_JSON* WINPR_JSON_ParseFromFileFP(FILE* fp);
103
111 WINPR_API size_t WINPR_JSON_GetArraySize(const WINPR_JSON* array);
112
121 WINPR_API WINPR_JSON* WINPR_JSON_GetArrayItem(const WINPR_JSON* array, size_t index);
122
131 WINPR_API WINPR_JSON* WINPR_JSON_GetObjectItem(const WINPR_JSON* object, const char* string);
132
141 WINPR_API WINPR_JSON* WINPR_JSON_GetObjectItemCaseSensitive(const WINPR_JSON* object,
142 const char* string);
143
151 WINPR_API BOOL WINPR_JSON_HasObjectItem(const WINPR_JSON* object, const char* string);
152
158 WINPR_API const char* WINPR_JSON_GetErrorPtr(void);
159
166 WINPR_API const char* WINPR_JSON_GetStringValue(WINPR_JSON* item);
167
174 WINPR_API double WINPR_JSON_GetNumberValue(const WINPR_JSON* item);
175
182 WINPR_API BOOL WINPR_JSON_IsInvalid(const WINPR_JSON* item);
183
190 WINPR_API BOOL WINPR_JSON_IsFalse(const WINPR_JSON* item);
191
198 WINPR_API BOOL WINPR_JSON_IsTrue(const WINPR_JSON* item);
199
206 WINPR_API BOOL WINPR_JSON_IsBool(const WINPR_JSON* item);
207
214 WINPR_API BOOL WINPR_JSON_IsNull(const WINPR_JSON* item);
215
222 WINPR_API BOOL WINPR_JSON_IsNumber(const WINPR_JSON* item);
223
230 WINPR_API BOOL WINPR_JSON_IsString(const WINPR_JSON* item);
231
238 WINPR_API BOOL WINPR_JSON_IsArray(const WINPR_JSON* item);
239
246 WINPR_API BOOL WINPR_JSON_IsObject(const WINPR_JSON* item);
247
253 WINPR_API WINPR_JSON* WINPR_JSON_CreateNull(void);
254
260 WINPR_API WINPR_JSON* WINPR_JSON_CreateTrue(void);
261
267 WINPR_API WINPR_JSON* WINPR_JSON_CreateFalse(void);
268
275 WINPR_API WINPR_JSON* WINPR_JSON_CreateBool(BOOL boolean);
276
283 WINPR_API WINPR_JSON* WINPR_JSON_CreateNumber(double num);
284
291 WINPR_API WINPR_JSON* WINPR_JSON_CreateString(const char* string);
292
298 WINPR_API WINPR_JSON* WINPR_JSON_CreateArray(void);
299
305 WINPR_API WINPR_JSON* WINPR_JSON_CreateObject(void);
306
314 WINPR_API WINPR_JSON* WINPR_JSON_AddNullToObject(WINPR_JSON* object, const char* name);
315
323 WINPR_API WINPR_JSON* WINPR_JSON_AddTrueToObject(WINPR_JSON* object, const char* name);
324
332 WINPR_API WINPR_JSON* WINPR_JSON_AddFalseToObject(WINPR_JSON* object, const char* name);
333
341 WINPR_API WINPR_JSON* WINPR_JSON_AddBoolToObject(WINPR_JSON* object, const char* name,
342 BOOL boolean);
343
351 WINPR_API WINPR_JSON* WINPR_JSON_AddNumberToObject(WINPR_JSON* object, const char* name,
352 double number);
353
361 WINPR_API WINPR_JSON* WINPR_JSON_AddIntegerToObject(WINPR_JSON* object, const char* name,
362 int64_t number);
363
371 WINPR_API WINPR_JSON* WINPR_JSON_AddStringToObject(WINPR_JSON* object, const char* name,
372 const char* string);
373
381 WINPR_API WINPR_JSON* WINPR_JSON_AddObjectToObject(WINPR_JSON* object, const char* name);
382
390 WINPR_API WINPR_JSON* WINPR_JSON_AddArrayToObject(WINPR_JSON* object, const char* name);
391
399 WINPR_API BOOL WINPR_JSON_AddItemToArray(WINPR_JSON* array, WINPR_JSON* item);
400
409 WINPR_ATTR_MALLOC(free, 1)
410 WINPR_ATTR_NODISCARD
411 WINPR_API char* WINPR_JSON_Print(WINPR_JSON* item);
412
421 WINPR_ATTR_MALLOC(free, 1)
422 WINPR_ATTR_NODISCARD
423 WINPR_API char* WINPR_JSON_PrintUnformatted(WINPR_JSON* item);
424
425#ifdef __cplusplus
426}
427#endif
428
431#endif
WINPR_API WINPR_JSON * WINPR_JSON_CreateBool(BOOL boolean)
WINPR_JSON_CreateBool.
Definition c-json.c:212
WINPR_API WINPR_JSON * WINPR_JSON_CreateString(const char *string)
WINPR_JSON_CreateString.
Definition c-json.c:222
WINPR_ATTR_NODISCARD 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 c-json.c:301
WINPR_ATTR_NODISCARD WINPR_API WINPR_JSON * WINPR_JSON_Parse(const char *value)
Parse a '\0' terminated JSON string.
Definition c-json.c:93
WINPR_API BOOL WINPR_JSON_HasObjectItem(const WINPR_JSON *object, const char *string)
Check if JSON has an object matching the name.
Definition c-json.c:132
WINPR_API WINPR_JSON * WINPR_JSON_AddNumberToObject(WINPR_JSON *object, const char *name, double number)
WINPR_JSON_AddNumberToObject.
Definition c-json.c:257
WINPR_API BOOL WINPR_JSON_IsNull(const WINPR_JSON *item)
Check if JSON item is Null.
Definition c-json.c:172
WINPR_API WINPR_JSON * WINPR_JSON_GetObjectItem(const WINPR_JSON *object, const char *string)
Return a pointer to an JSON object item.
Definition c-json.c:122
WINPR_API BOOL WINPR_JSON_IsString(const WINPR_JSON *item)
Check if JSON item is of type String.
Definition c-json.c:182
WINPR_API BOOL WINPR_JSON_AddItemToArray(WINPR_JSON *array, WINPR_JSON *item)
Add an item to an existing array.
Definition c-json.c:279
WINPR_API WINPR_JSON * WINPR_JSON_AddArrayToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddArrayToObject.
Definition c-json.c:291
WINPR_API BOOL WINPR_JSON_IsBool(const WINPR_JSON *item)
Check if JSON item is of type BOOL.
Definition c-json.c:167
WINPR_API double WINPR_JSON_GetNumberValue(const WINPR_JSON *item)
Return the Number value of a JSON item.
Definition c-json.c:147
WINPR_ATTR_NODISCARD WINPR_API WINPR_JSON * WINPR_JSON_ParseFromFile(const char *filename)
Parse a JSON string read from a file filename.
Definition json.c:27
WINPR_API WINPR_JSON * WINPR_JSON_AddTrueToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddTrueToObject.
Definition c-json.c:242
WINPR_API WINPR_JSON * WINPR_JSON_CreateObject(void)
WINPR_JSON_CreateObject.
Definition c-json.c:232
WINPR_API WINPR_JSON * WINPR_JSON_CreateArray(void)
WINPR_JSON_CreateArray.
Definition c-json.c:227
WINPR_API int WINPR_JSON_version(char *buffer, size_t len)
Get the library version string.
Definition c-json.c:88
WINPR_API WINPR_JSON * WINPR_JSON_AddFalseToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddFalseToObject.
Definition c-json.c:247
WINPR_API BOOL WINPR_JSON_IsNumber(const WINPR_JSON *item)
Check if JSON item is of type Number.
Definition c-json.c:177
WINPR_API WINPR_JSON * WINPR_JSON_GetArrayItem(const WINPR_JSON *array, size_t index)
Return a pointer to an item in the array.
Definition c-json.c:108
WINPR_ATTR_NODISCARD 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 c-json.c:296
WINPR_API WINPR_JSON * WINPR_JSON_GetObjectItemCaseSensitive(const WINPR_JSON *object, const char *string)
Same as WINPR_JSON_GetObjectItem but with case sensitive matching.
Definition c-json.c:127
WINPR_API WINPR_JSON * WINPR_JSON_AddStringToObject(WINPR_JSON *object, const char *name, const char *string)
WINPR_JSON_AddStringToObject.
Definition c-json.c:269
WINPR_ATTR_NODISCARD WINPR_API WINPR_JSON * WINPR_JSON_ParseWithLength(const char *value, size_t buffer_length)
Parse a JSON string.
Definition c-json.c:98
WINPR_ATTR_NODISCARD WINPR_API WINPR_JSON * WINPR_JSON_ParseFromFileFP(FILE *fp)
Parse a JSON string read from a FILE.
Definition json.c:37
WINPR_API WINPR_JSON * WINPR_JSON_CreateFalse(void)
WINPR_JSON_CreateFalse.
Definition c-json.c:207
WINPR_API WINPR_JSON * WINPR_JSON_CreateNumber(double num)
WINPR_JSON_CreateNumber.
Definition c-json.c:217
WINPR_API BOOL WINPR_JSON_IsObject(const WINPR_JSON *item)
Check if JSON item is of type Object.
Definition c-json.c:192
WINPR_API WINPR_JSON * WINPR_JSON_AddBoolToObject(WINPR_JSON *object, const char *name, BOOL boolean)
WINPR_JSON_AddBoolToObject.
Definition c-json.c:252
WINPR_API BOOL WINPR_JSON_IsInvalid(const WINPR_JSON *item)
Check if JSON item is valid.
Definition c-json.c:152
WINPR_API WINPR_JSON * WINPR_JSON_CreateNull(void)
WINPR_JSON_CreateNull.
Definition c-json.c:197
WINPR_API const char * WINPR_JSON_GetStringValue(WINPR_JSON *item)
Return the String value of a JSON item.
Definition c-json.c:142
WINPR_API WINPR_JSON * WINPR_JSON_AddNullToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddNullToObject.
Definition c-json.c:237
WINPR_API WINPR_JSON * WINPR_JSON_AddIntegerToObject(WINPR_JSON *object, const char *name, int64_t number)
WINPR_JSON_AddIntegerToObject.
Definition c-json.c:262
WINPR_API WINPR_JSON * WINPR_JSON_CreateTrue(void)
WINPR_JSON_CreateTrue.
Definition c-json.c:202
WINPR_API BOOL WINPR_JSON_IsFalse(const WINPR_JSON *item)
Check if JSON item is BOOL value False.
Definition c-json.c:157
WINPR_API void WINPR_JSON_Delete(WINPR_JSON *item)
Delete a WinPR JSON wrapper object.
Definition c-json.c:103
WINPR_API size_t WINPR_JSON_GetArraySize(const WINPR_JSON *array)
Get the number of arrayitems from an array.
Definition c-json.c:114
WINPR_API BOOL WINPR_JSON_IsArray(const WINPR_JSON *item)
Check if JSON item is of type Array.
Definition c-json.c:187
WINPR_API const char * WINPR_JSON_GetErrorPtr(void)
Return an error string.
Definition c-json.c:137
WINPR_API WINPR_JSON * WINPR_JSON_AddObjectToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddObjectToObject.
Definition c-json.c:274
WINPR_API BOOL WINPR_JSON_IsTrue(const WINPR_JSON *item)
Check if JSON item is BOOL value True.
Definition c-json.c:162