46#ifdef JSONTREE_CONF_MAX_DEPTH
47#define JSONTREE_MAX_DEPTH JSONTREE_CONF_MAX_DEPTH
49#define JSONTREE_MAX_DEPTH 10
52#ifdef JSONTREE_CONF_PRETTY
53#define JSONTREE_PRETTY JSONTREE_CONF_PRETTY
55#define JSONTREE_PRETTY 0
58struct jsontree_context {
59 struct jsontree_value *values[JSONTREE_MAX_DEPTH];
60 uint16_t index[JSONTREE_MAX_DEPTH];
67struct jsontree_value {
72struct jsontree_string {
88struct jsonparse_state;
89struct jsontree_callback {
91 int (*
output)(
struct jsontree_context *js_ctx);
92 int (* set)(
struct jsontree_context *js_ctx,
struct jsonparse_state *parser);
97 struct jsontree_value *value;
100struct jsontree_object {
103 struct jsontree_pair *pairs;
106struct jsontree_array {
109 struct jsontree_value **values;
117#define JSONTREE_STRING(text) {JSON_TYPE_STRING, (text)}
118#define JSONTREE_PAIR(name, value) {(name), (struct jsontree_value *)(value)}
119#define JSONTREE_CALLBACK(output, set) {JSON_TYPE_CALLBACK, (output), (set)}
121#define JSONTREE_OBJECT(name, ...) \
122 static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__}; \
123 static struct jsontree_object name = { \
125 sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair), \
126 jsontree_pair_##name }
128#define JSONTREE_OBJECT_EXT(name, ...) \
129 static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__}; \
130 struct jsontree_object name = { \
132 sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair), \
133 jsontree_pair_##name }
135#define JSONTREE_ARRAY(name, count) \
136 static struct jsontree_value *jsontree_value##name[count]; \
137 static struct jsontree_array name = { \
140 jsontree_value##name }
142void jsontree_setup(
struct jsontree_context *js_ctx,
143 struct jsontree_value *root,
int (* putchar)(
int));
144void jsontree_reset(
struct jsontree_context *js_ctx);
146const char *jsontree_path_name(
const struct jsontree_context *js_ctx,
149void jsontree_write_uint(
const struct jsontree_context *js_ctx,
151void jsontree_write_int(
const struct jsontree_context *js_ctx,
int value);
152void jsontree_write_atom(
const struct jsontree_context *js_ctx,
154void jsontree_write_string(
const struct jsontree_context *js_ctx,
156int jsontree_print_next(
struct jsontree_context *js_ctx);
157struct jsontree_value *jsontree_find_next(
struct jsontree_context *js_ctx,
static volatile uint64_t count
Num.
static uint8_t output(const linkaddr_t *localdest)
Take an IP packet and format it to be sent on an 802.15.4 network using 6lowpan.
A few JSON defines used for parsing and generating JSON.