43 #include "contiki-conf.h" 
   46 #ifdef JSONTREE_CONF_MAX_DEPTH 
   47 #define JSONTREE_MAX_DEPTH JSONTREE_CONF_MAX_DEPTH 
   49 #define JSONTREE_MAX_DEPTH 10 
   52 struct jsontree_context {
 
   53   struct jsontree_value *values[JSONTREE_MAX_DEPTH];
 
   54   uint16_t index[JSONTREE_MAX_DEPTH];
 
   61 struct jsontree_value {
 
   66 struct jsontree_string {
 
   77 struct jsonparse_state;
 
   78 struct jsontree_callback {
 
   80   int (* output)(
struct jsontree_context *js_ctx);
 
   81   int (* set)(
struct jsontree_context *js_ctx, 
struct jsonparse_state *parser);
 
   84 struct jsontree_pair {
 
   86   struct jsontree_value *value;
 
   89 struct jsontree_object {
 
   92   struct jsontree_pair *pairs;
 
   95 struct jsontree_array {
 
   98   struct jsontree_value **values;
 
  101 #define JSONTREE_STRING(text) {JSON_TYPE_STRING, (text)} 
  102 #define JSONTREE_PAIR(name, value) {(name), (struct jsontree_value *)(value)} 
  103 #define JSONTREE_CALLBACK(output, set) {JSON_TYPE_CALLBACK, (output), (set)} 
  105 #define JSONTREE_OBJECT(name, ...)                                      \ 
  106   static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__};   \ 
  107   static struct jsontree_object name = {                                \ 
  109     sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair),          \ 
  110     jsontree_pair_##name } 
  112 #define JSONTREE_OBJECT_EXT(name, ...)                                  \ 
  113   static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__};   \ 
  114   struct jsontree_object name = {                                       \ 
  116     sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair),          \ 
  117     jsontree_pair_##name } 
  119 #define JSONTREE_ARRAY(name, count)                                     \ 
  120   static struct jsontree_value *jsontree_value##name[count];            \ 
  121   static struct jsontree_array name = {                                 \ 
  124     jsontree_value##name }          
  126 void jsontree_setup(
struct jsontree_context *js_ctx,
 
  127                     struct jsontree_value *root, 
int (* putchar)(
int));
 
  128 void jsontree_reset(
struct jsontree_context *js_ctx);
 
  130 const char *jsontree_path_name(
const struct jsontree_context *js_ctx,
 
  133 void jsontree_write_int(
const struct jsontree_context *js_ctx, 
int value);
 
  134 void jsontree_write_atom(
const struct jsontree_context *js_ctx,
 
  136 void jsontree_write_string(
const struct jsontree_context *js_ctx,
 
  138 int jsontree_print_next(
struct jsontree_context *js_ctx);
 
  139 struct jsontree_value *jsontree_find_next(
struct jsontree_context *js_ctx,
 
    A few JSON defines used for parsing and generating JSON.