Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
jsmn.h
Go to the documentation of this file.
1
24#ifndef __JSMN_H_
25#define __JSMN_H_
26
27#include "ws_symbol_export.h"
28/* Defining JSMN_PARENT_LINKS configures jsmn to have each node store a link
29 to its parent node. This greatly improve parsing performance for large files
30 while only consuming an extra 'int' per node. */
31#define JSMN_PARENT_LINKS
32
33#include <stddef.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
46typedef enum {
47 JSMN_UNDEFINED = 0,
48 JSMN_OBJECT = 1,
49 JSMN_ARRAY = 2,
50 JSMN_STRING = 3,
51 JSMN_PRIMITIVE = 4
53
54enum jsmnerr {
55 /* Not enough tokens were provided */
56 JSMN_ERROR_NOMEM = -1,
57 /* Invalid character inside JSON string */
58 JSMN_ERROR_INVAL = -2,
59 /* The string is not a full JSON packet, more bytes expected */
60 JSMN_ERROR_PART = -3
61};
62
69typedef struct {
70 jsmntype_t type;
71 int start;
72 int end;
73 int size;
74#ifdef JSMN_PARENT_LINKS
75 int parent;
76#endif
77} jsmntok_t;
78
83typedef struct {
84 unsigned int pos; /* offset in the JSON string */
85 unsigned int toknext; /* next token to allocate */
86 int toksuper; /* superior token node, e.g parent object or array */
88
92WS_DLL_PUBLIC void jsmn_init(jsmn_parser *parser);
93
98WS_DLL_PUBLIC int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
99 jsmntok_t *tokens, unsigned int num_tokens);
100
101#ifdef __cplusplus
102}
103#endif
104
105#endif /* __JSMN_H_ */
jsmntype_t
Definition jsmn.h:46
WS_DLL_PUBLIC void jsmn_init(jsmn_parser *parser)
Definition jsmn.c:328
WS_DLL_PUBLIC int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, unsigned int num_tokens)
Definition jsmn.c:173
Definition jsmn.h:83
Definition jsmn.h:69