![]() |
libwebsockets
Lightweight C library for HTML5 websockets
|
Data Structures | |
struct | _lejp_stack |
struct | lejp_ctx |
Typedefs | |
typedef signed char(* | lejp_callback) (struct lejp_ctx *ctx, char reason) |
Functions | |
LWS_EXTERN signed char | _lejp_callback (struct lejp_ctx *ctx, char reason) |
LWS_VISIBLE LWS_EXTERN void | lejp_construct (struct lejp_ctx *ctx, signed char(*callback)(struct lejp_ctx *ctx, char reason), void *user, const char *const *paths, unsigned char paths_count) |
LWS_VISIBLE LWS_EXTERN void | lejp_destruct (struct lejp_ctx *ctx) |
LWS_VISIBLE LWS_EXTERN int | lejp_parse (struct lejp_ctx *ctx, const unsigned char *json, int len) |
LWS_VISIBLE LWS_EXTERN void | lejp_change_callback (struct lejp_ctx *ctx, signed char(*callback)(struct lejp_ctx *ctx, char reason)) |
LWS_VISIBLE LWS_EXTERN int | lejp_get_wildcard (struct lejp_ctx *ctx, int wildcard, char *dest, int len) |
LEJP is an extremely lightweight JSON stream parser included in lws.
LWS_EXTERN signed char _lejp_callback | ( | struct lejp_ctx * | ctx, |
char | reason | ||
) |
#include <lib/libwebsockets.h>
_lejp_callback() - User parser actions
ctx | LEJP context |
reason | Callback reason Your user callback is associated with the context at construction time, and receives calls as the parsing progresses. All of the callbacks may be ignored and just return 0. The reasons it might get called, found in @reason, are: |
LEJPCB_CONSTRUCTED: The context was just constructed... you might want to perform one-time allocation for the life of the context.
LEJPCB_DESTRUCTED: The context is being destructed... if you made any allocations at construction-time, you can free them now
LEJPCB_START: Parsing is beginning at the first byte of input
LEJPCB_COMPLETE: Parsing has completed successfully. You'll get a 0 or positive return code from lejp_parse indicating the amount of unused bytes left in the input buffer
LEJPCB_FAILED: Parsing failed. You'll get a negative error code returned from lejp_parse
LEJPCB_PAIR_NAME: When a "name":"value" pair has had the name parsed, this callback occurs. You can find the new name at the end of ctx->path[]
LEJPCB_VAL_TRUE: The "true" value appeared
LEJPCB_VAL_FALSE: The "false" value appeared
LEJPCB_VAL_NULL: The "null" value appeared
LEJPCB_VAL_NUM_INT: A string representing an integer is in ctx->buf
LEJPCB_VAL_NUM_FLOAT: A string representing a float is in ctx->buf
LEJPCB_VAL_STR_START: We are starting to parse a string, no data yet
LEJPCB_VAL_STR_CHUNK: We parsed LEJP_STRING_CHUNK -1 bytes of string data in ctx->buf, which is as much as we can buffer, so we are spilling it. If all your strings are less than LEJP_STRING_CHUNK - 1 bytes, you will never see this callback.
LEJPCB_VAL_STR_END: String parsing has completed, the last chunk of the string is in ctx->buf.
LEJPCB_ARRAY_START: An array started
LEJPCB_ARRAY_END: An array ended
LEJPCB_OBJECT_START: An object started
LEJPCB_OBJECT_END: An object ended