FreeRDP
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
35 extern "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_API size_t WINPR_JSON_GetArraySize(const WINPR_JSON* array);
88 
97  WINPR_API WINPR_JSON* WINPR_JSON_GetArrayItem(const WINPR_JSON* array, size_t index);
98 
106  WINPR_API WINPR_JSON* WINPR_JSON_GetObjectItem(const WINPR_JSON* object, const char* string);
107 
116  WINPR_API WINPR_JSON* WINPR_JSON_GetObjectItemCaseSensitive(const WINPR_JSON* object,
117  const char* string);
118 
126  WINPR_API BOOL WINPR_JSON_HasObjectItem(const WINPR_JSON* object, const char* string);
127 
133  WINPR_API const char* WINPR_JSON_GetErrorPtr(void);
134 
141  WINPR_API const char* WINPR_JSON_GetStringValue(WINPR_JSON* item);
142 
149  WINPR_API double WINPR_JSON_GetNumberValue(const WINPR_JSON* item);
150 
157  WINPR_API BOOL WINPR_JSON_IsInvalid(const WINPR_JSON* item);
158 
165  WINPR_API BOOL WINPR_JSON_IsFalse(const WINPR_JSON* item);
166 
173  WINPR_API BOOL WINPR_JSON_IsTrue(const WINPR_JSON* item);
174 
181  WINPR_API BOOL WINPR_JSON_IsBool(const WINPR_JSON* item);
182 
189  WINPR_API BOOL WINPR_JSON_IsNull(const WINPR_JSON* item);
190 
197  WINPR_API BOOL WINPR_JSON_IsNumber(const WINPR_JSON* item);
198 
205  WINPR_API BOOL WINPR_JSON_IsString(const WINPR_JSON* item);
206 
213  WINPR_API BOOL WINPR_JSON_IsArray(const WINPR_JSON* item);
214 
221  WINPR_API BOOL WINPR_JSON_IsObject(const WINPR_JSON* item);
222 
228  WINPR_API WINPR_JSON* WINPR_JSON_CreateNull(void);
229 
235  WINPR_API WINPR_JSON* WINPR_JSON_CreateTrue(void);
236 
242  WINPR_API WINPR_JSON* WINPR_JSON_CreateFalse(void);
243 
250  WINPR_API WINPR_JSON* WINPR_JSON_CreateBool(BOOL boolean);
251 
258  WINPR_API WINPR_JSON* WINPR_JSON_CreateNumber(double num);
259 
266  WINPR_API WINPR_JSON* WINPR_JSON_CreateString(const char* string);
267 
273  WINPR_API WINPR_JSON* WINPR_JSON_CreateArray(void);
274 
280  WINPR_API WINPR_JSON* WINPR_JSON_CreateObject(void);
281 
289  WINPR_API WINPR_JSON* WINPR_JSON_AddNullToObject(WINPR_JSON* object, const char* name);
290 
298  WINPR_API WINPR_JSON* WINPR_JSON_AddTrueToObject(WINPR_JSON* object, const char* name);
299 
307  WINPR_API WINPR_JSON* WINPR_JSON_AddFalseToObject(WINPR_JSON* object, const char* name);
308 
316  WINPR_API WINPR_JSON* WINPR_JSON_AddBoolToObject(WINPR_JSON* object, const char* name,
317  BOOL boolean);
318 
326  WINPR_API WINPR_JSON* WINPR_JSON_AddNumberToObject(WINPR_JSON* object, const char* name,
327  double number);
328 
336  WINPR_API WINPR_JSON* WINPR_JSON_AddStringToObject(WINPR_JSON* object, const char* name,
337  const char* string);
338 
346  WINPR_API WINPR_JSON* WINPR_JSON_AddObjectToObject(WINPR_JSON* object, const char* name);
347 
355  WINPR_API WINPR_JSON* WINPR_JSON_AddArrayToObject(WINPR_JSON* object, const char* name);
356 
364  WINPR_API BOOL WINPR_JSON_AddItemToArray(WINPR_JSON* array, WINPR_JSON* item);
365 
374  WINPR_API char* WINPR_JSON_Print(WINPR_JSON* item);
375 
384  WINPR_API char* WINPR_JSON_PrintUnformatted(WINPR_JSON* item);
385 
386 #ifdef __cplusplus
387 }
388 #endif
389 
392 #endif
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_ParseWithLength(const char *value, size_t buffer_length)
Parse a JSON string.
Definition: json.c:125
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_AddObjectToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddObjectToObject.
Definition: json.c:593
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 BOOL WINPR_JSON_IsNull(const WINPR_JSON *item)
Check if JSON item is Null.
Definition: json.c:324
WINPR_API BOOL WINPR_JSON_IsString(const WINPR_JSON *item)
Check if JSON item is of type String.
Definition: json.c:349
WINPR_API WINPR_JSON * WINPR_JSON_AddTrueToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddTrueToObject.
Definition: json.c:495
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_AddNumberToObject(WINPR_JSON *object, const char *name, double number)
WINPR_JSON_AddNumberToObject.
Definition: json.c:553
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 int WINPR_JSON_version(char *buffer, size_t len)
Get the library version string.
Definition: json.c:102
WINPR_API WINPR_JSON * WINPR_JSON_Parse(const char *value)
Parse a '\0' terminated JSON string.
Definition: json.c:113
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:647
WINPR_API WINPR_JSON * WINPR_JSON_CreateNumber(double num)
WINPR_JSON_CreateNumber.
Definition: json.c:430
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_GetObjectItemCaseSensitive(const WINPR_JSON *object, const char *string)
Same as WINPR_JSON_GetObjectItem but with case insensitive matching.
Definition: json.c:197
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:662
WINPR_API WINPR_JSON * WINPR_JSON_CreateArray(void)
WINPR_JSON_CreateArray.
Definition: json.c:454
WINPR_API WINPR_JSON * WINPR_JSON_CreateNull(void)
WINPR_JSON_CreateNull.
Definition: json.c:385
WINPR_API WINPR_JSON * WINPR_JSON_CreateFalse(void)
WINPR_JSON_CreateFalse.
Definition: json.c:407
WINPR_API WINPR_JSON * WINPR_JSON_AddArrayToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddArrayToObject.
Definition: json.c:628
WINPR_API WINPR_JSON * WINPR_JSON_AddBoolToObject(WINPR_JSON *object, const char *name, BOOL boolean)
WINPR_JSON_AddBoolToObject.
Definition: json.c:533
WINPR_API WINPR_JSON * WINPR_JSON_AddNullToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddNullToObject.
Definition: json.c:476
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_GetArrayItem(const WINPR_JSON *array, size_t index)
Return a pointer to an item in the array.
Definition: json.c:155
WINPR_API BOOL WINPR_JSON_IsInvalid(const WINPR_JSON *item)
Check if JSON item is valid.
Definition: json.c:258
WINPR_API const char * WINPR_JSON_GetErrorPtr(void)
Return an error string.
Definition: json.c:223
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 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 WINPR_JSON * WINPR_JSON_CreateObject(void)
WINPR_JSON_CreateObject.
Definition: json.c:465
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 WINPR_JSON * WINPR_JSON_CreateString(const char *string)
WINPR_JSON_CreateString.
Definition: json.c:442
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_GetStringValue(WINPR_JSON *item)
Return the String value of a JSON item.
Definition: json.c:234
WINPR_API WINPR_JSON * WINPR_JSON_CreateBool(BOOL boolean)
WINPR_JSON_CreateBool.
Definition: json.c:418
WINPR_API BOOL WINPR_JSON_IsTrue(const WINPR_JSON *item)
Check if JSON item is BOOL value True.
Definition: json.c:297