cJSON.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef cJSON__h
  2. #define cJSON__h
  3. #include "main.h"
  4. #ifdef __cplusplus
  5. extern "C"
  6. {
  7. #endif
  8. /* cJSON Types: */
  9. #define cJSON_False 0
  10. #define cJSON_True 1
  11. #define cJSON_NULL 2
  12. #define cJSON_Number 3
  13. #define cJSON_String 4
  14. #define cJSON_Array 5
  15. #define cJSON_Object 6
  16. #define cJSON_IsReference 256
  17. /* The cJSON structure: */
  18. typedef struct cJSON {
  19. struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
  20. struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
  21. int type; /* The type of the item, as above. */
  22. char *valuestring; /* The item's string, if type==cJSON_String */
  23. int valueint; /* The item's number, if type==cJSON_Number */
  24. double valuedouble; /* The item's number, if type==cJSON_Number */
  25. char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
  26. } cJSON;
  27. /* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
  28. extern cJSON *cJSON_Parse(const char *value);
  29. /* Delete a cJSON entity and all subentities. */
  30. extern void cJSON_Delete(cJSON *c);
  31. /* Get item "string" from object. Case insensitive. */
  32. extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
  33. /* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
  34. extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated);
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38. #endif