Include this header file to use coreJSON in your application. More...
#include <stddef.h>Go to the source code of this file.
| Enumerations | |
| enum | JSONStatus_t { JSONPartial = 0 , JSONSuccess , JSONIllegalDocument , JSONMaxDepthExceeded , JSONNotFound , JSONNullParameter , JSONBadParameter } | 
| Return codes from coreJSON library functions.  More... | |
| Functions | |
| JSONStatus_t | JSON_Validate (const char *buf, size_t max) | 
| Parse a buffer to determine if it contains a valid JSON document.  More... | |
| JSONStatus_t | JSON_Search (char *buf, size_t max, const char *queryKey, size_t queryKeyLength, char separator, char **outValue, size_t *outValueLength) | 
| Find a key in a JSON object and output the pointer outValueto its value.  More... | |
Include this header file to use coreJSON in your application.
| JSONStatus_t JSON_Validate | ( | const char * | buf, | 
| size_t | max | ||
| ) | 
Parse a buffer to determine if it contains a valid JSON document.
| [in] | buf | The buffer to parse. | 
| [in] | max | The size of the buffer. | 
Example
See core_json.h for docs.
Verify that the entire buffer contains exactly one scalar or collection within optional whitespace.
| JSONStatus_t JSON_Search | ( | char * | buf, | 
| size_t | max, | ||
| const char * | queryKey, | ||
| size_t | queryKeyLength, | ||
| char | separator, | ||
| char ** | outValue, | ||
| size_t * | outValueLength | ||
| ) | 
Find a key in a JSON object and output the pointer outValue to its value. 
The JSON document must contain an object (e.g., {"key":"value"}). Any value may also be an object and so forth to a maximum depth. A search may descend through nested objects when the queryKey contains matching key strings joined by a separator.
For example, if buf contains {"foo":"abc","bar":{"foo":"xyz"}}, then a search for 'foo' would output abc, 'bar' would output {"foo":"xyz"}, and a search for 'bar.foo' would output xyz (given separator is specified as '.').
On success, the pointer outValue points to a location in buf. No null termination is done for the value. For valid JSON it is safe to place a null character at the end of the value, so long as the character replaced is put back before running another search.
| [in] | buf | The buffer to search. | 
| [in] | max | size of the buffer. | 
| [in] | queryKey | The key to search for. | 
| [in] | queryKeyLength | Length of the key. | 
| [in] | separator | A character between a key and a sub-key in queryKey. | 
| [out] | outValue | A pointer to receive the address of the value found. | 
| [out] | outValueLength | A pointer to receive the length of the value found. | 
Example
See core_json.h for docs.
Handle a nested search by iterating over the parts of the queryKey.