X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fgraph.c;h=544a606d80cf06b1d2d728650e5cde56e6cf74ed;hb=33e56e5052a805658254653ea7721bbd95a7fd51;hp=deeb05a649aa50a11bec580acde42b63c11e8e1e;hpb=e44a32c44326ebe6ee10333138fabc337c067281;p=collection4.git diff --git a/src/graph.c b/src/graph.c index deeb05a..544a606 100644 --- a/src/graph.c +++ b/src/graph.c @@ -633,10 +633,19 @@ int graph_to_json (const graph_config_t *cfg, /* {{{ */ return (EINVAL); yajl_gen_map_open (handler); + + yajl_gen_string (handler, + (unsigned char *) "title", + (unsigned int) strlen ("title")); + yajl_gen_string (handler, + (unsigned char *) cfg->title, + (unsigned int) strlen (cfg->title)); + yajl_gen_string (handler, (unsigned char *) "select", (unsigned int) strlen ("select")); ident_to_json (cfg->select, handler); + yajl_gen_string (handler, (unsigned char *) "instances", (unsigned int) strlen ("instances")); @@ -644,12 +653,14 @@ int graph_to_json (const graph_config_t *cfg, /* {{{ */ for (i = 0; i < cfg->instances_num; i++) inst_to_json (cfg->instances[i], handler); yajl_gen_array_close (handler); + yajl_gen_map_close (handler); return (0); } /* }}} int graph_to_json */ -int graph_def_to_json (const graph_config_t *cfg, /* {{{ */ +int graph_def_to_json (graph_config_t *cfg, /* {{{ */ + graph_instance_t *inst, yajl_gen handler) { #define yajl_gen_string_cast(h,p,l) \ @@ -676,7 +687,18 @@ int graph_def_to_json (const graph_config_t *cfg, /* {{{ */ yajl_gen_bool (handler, cfg->show_zero); yajl_gen_string_cast (handler, "defs", strlen ("defs")); - def_to_json (cfg->defs, handler); + if (cfg->defs == NULL) + { + graph_def_t *defs; + + defs = inst_get_default_defs (cfg, inst); + def_to_json (defs, handler); + def_destroy (defs); + } + else + { + def_to_json (cfg->defs, handler); + } yajl_gen_map_close (handler);