Go to the source code of this file.
Typedefs | |
typedef void(* | le_json_EventHandler_t) (le_json_Event_t event) |
typedef void(* | le_json_ErrorHandler_t) (le_json_Error_t error, const char *msg) |
typedef struct le_json_ParsingSession * | le_json_ParsingSessionRef_t |
Functions | |
le_json_ParsingSessionRef_t | le_json_Parse (int fd, le_json_EventHandler_t eventHandler, le_json_ErrorHandler_t errorHandler, void *opaquePtr) |
void | le_json_Cleanup (le_json_ParsingSessionRef_t session) |
void | le_json_SetEventHandler (le_json_EventHandler_t callbackFunc) |
le_json_ContextType_t | le_json_GetContextType (void) |
void | le_json_SetOpaquePtr (void *ptr) |
void * | le_json_GetOpaquePtr (void) |
void | le_json_SetErrorHandler (le_json_ErrorHandler_t callbackFunc) |
const char * | le_json_GetString (void) |
double | le_json_GetNumber (void) |
const char * | le_json_GetEventName (le_json_Event_t event) |
const char * | le_json_GetContextName (le_json_ContextType_t context) |
size_t | le_json_GetBytesRead (le_json_ParsingSessionRef_t session) |
le_json_ParsingSessionRef_t | le_json_GetSession (void) |
Legato JSON Parsing API include file.
Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.
typedef void(* le_json_ErrorHandler_t) (le_json_Error_t error, const char *msg) |
Callbacks for errors look like this.
error | [in] Indicates what type of error occured. |
msg | [in] Human-readable message describing the error. (Valid until handler returns.) |
typedef void(* le_json_EventHandler_t) (le_json_Event_t event) |
Callbacks for (non-error) parsing events look like this.
event | [in] Indicates what type of event occured. |
typedef struct le_json_ParsingSession* le_json_ParsingSessionRef_t |
Parsing session reference. Refers to a parsing session started by le_json_Parse(). Pass this to le_json_Cleanup() to stop the parsing and clean up memory allocated by the parser.
Enumeration of the different types of "contexts" that can exist during a parsing session.
enum le_json_Error_t |
enum le_json_Event_t |
Enumeration of all the different events that can be reported during JSON document parsing.
Enumerator | |
---|---|
LE_JSON_OBJECT_START |
object started, subsequent object members are part of this object |
LE_JSON_OBJECT_MEMBER |
object member name received: Call le_json_GetString() to get name |
LE_JSON_OBJECT_END |
object finished, subsequent members/values are outside this object |
LE_JSON_ARRAY_START |
array started, upcoming values are elements of this array |
LE_JSON_ARRAY_END |
array finished, subsequent values are outside this array |
LE_JSON_STRING |
string value received: call le_json_GetString() to get value |
LE_JSON_NUMBER |
number value received: call le_json_GetNumber() to get value |
LE_JSON_TRUE |
true value received |
LE_JSON_FALSE |
false value received |
LE_JSON_NULL |
null value received |
LE_JSON_DOC_END |
End of the document reached. Parsing has stopped. |
void le_json_Cleanup | ( | le_json_ParsingSessionRef_t | session | ) |
Stops parsing and cleans up memory allocated by the parser.
session | The parsing session to clean up (see le_json_Parse()). |
size_t le_json_GetBytesRead | ( | le_json_ParsingSessionRef_t | session | ) |
session | Parsing session. |
const char* le_json_GetContextName | ( | le_json_ContextType_t | context | ) |
le_json_ContextType_t le_json_GetContextType | ( | void | ) |
Get the type of parsing context that the parser is currently in.
const char* le_json_GetEventName | ( | le_json_Event_t | event | ) |
double le_json_GetNumber | ( | void | ) |
Fetches the value of a parsed number.
void* le_json_GetOpaquePtr | ( | void | ) |
Get the opaque pointer attached to the parser.
le_json_ParsingSessionRef_t le_json_GetSession | ( | void | ) |
For use by an event handler or error handler to fetch the JSON parsing session reference for the session that called its handler function.
const char* le_json_GetString | ( | void | ) |
Fetches a pointer to a string value or object member name.
This pointer is only valid until the event handler returns.
le_json_ParsingSessionRef_t le_json_Parse | ( | int | fd, |
le_json_EventHandler_t | eventHandler, | ||
le_json_ErrorHandler_t | errorHandler, | ||
void * | opaquePtr | ||
) |
Parse a JSON document received via a file descriptor.
fd | File descriptor to read the JSON document from. |
eventHandler | Function to call when normal parsing events happen. |
errorHandler | Function to call when errors happen. |
opaquePtr | Opaque pointer to be fetched by handlers using le_json_GetOpaquePtr(). |
void le_json_SetErrorHandler | ( | le_json_ErrorHandler_t | callbackFunc | ) |
Set the error handler function
callbackFunc | Function to call when parsing errors happen. |
void le_json_SetEventHandler | ( | le_json_EventHandler_t | callbackFunc | ) |
Set the current context's event handler function.
callbackFunc | Function to call when parsing events happen. |
void le_json_SetOpaquePtr | ( | void * | ptr | ) |
Set the opaque pointer attached to the parser.
ptr | Opaque pointer to be fetched using le_json_GetOpaquePtr(). |