From: Florian Forster Date: Thu, 9 Sep 2010 07:55:58 +0000 (+0200) Subject: src/graph_ident.c: Fix generation of JSON data. X-Git-Tag: v4.0.0~31 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a9998442e628891b69699d7a2a0c85f46f9cdcc9;p=collection4.git src/graph_ident.c: Fix generation of JSON data. --- diff --git a/src/graph_ident.c b/src/graph_ident.c index e2d3cd6..9c8bc6e 100644 --- a/src/graph_ident.c +++ b/src/graph_ident.c @@ -21,6 +21,8 @@ * Florian octo Forster **/ +#include "config.h" + #include #include #include @@ -30,6 +32,7 @@ #include /* PATH_MAX */ #include #include +#include #include "graph_ident.h" #include "common.h" @@ -558,17 +561,20 @@ static int ident_data_to_json__get_ident_data ( ident_data_to_json__data_t *data = user_data; size_t i; - yajl_gen_map_open (data->handler); + yajl_gen_array_open (data->handler); for (i = 0; i < dp_num; i++) { - yajl_gen_map_open (data->handler); + yajl_gen_array_open (data->handler); yajl_gen_integer (data->handler, (long) dp[i].time.tv_sec); - yajl_gen_double (data->handler, dp[i].value); - yajl_gen_map_close (data->handler); + if (isnan (dp[i].value)) + yajl_gen_null (data->handler); + else + yajl_gen_double (data->handler, dp[i].value); + yajl_gen_array_close (data->handler); } - yajl_gen_map_close (data->handler); + yajl_gen_array_close (data->handler); return (0); } /* }}} int ident_data_to_json__get_ident_data */