Commit b1401a81 authored by Tollef Fog Heen's avatar Tollef Fog Heen

Simplify json callback

parent 64a8c2a2
...@@ -92,8 +92,6 @@ do_json_cb(void *priv, const struct VSC_point * const pt) ...@@ -92,8 +92,6 @@ do_json_cb(void *priv, const struct VSC_point * const pt)
{ {
uint64_t val; uint64_t val;
int *jp; int *jp;
char jsonkey[255];
char jsontmp[255];
jp = priv; jp = priv;
...@@ -101,18 +99,14 @@ do_json_cb(void *priv, const struct VSC_point * const pt) ...@@ -101,18 +99,14 @@ do_json_cb(void *priv, const struct VSC_point * const pt)
val = *(const volatile uint64_t*)pt->ptr; val = *(const volatile uint64_t*)pt->ptr;
if (*jp) *jp = 0; else printf(",\n"); if (*jp) *jp = 0; else printf(",\n");
jsonkey[0] = '\0';
printf("\t\"");
/* build the JSON key name. */ /* build the JSON key name. */
if (strcmp(pt->ident, "") && strcmp(pt->class, "")) sprintf(jsonkey, "%s.%s", pt->class, pt->ident); if (pt->class[0])
if (strcmp(pt->ident, "") && !strcmp(pt->class, "")) sprintf(jsonkey, "%s", pt->ident); printf("%s.", pt->class);
if (!strcmp(pt->ident, "") && strcmp(pt->class, "")) sprintf(jsonkey, "%s", pt->class); if (pt->ident[0])
printf("%s.", pt->ident);
strcpy(jsontmp, jsonkey); printf("%s\": {", pt->name);
if (strcmp(jsonkey, "")) sprintf(jsonkey, "%s.%s", jsontmp, pt->name);
else strcpy(jsonkey, pt->name);
printf("\t\"%s\": {", jsonkey);
if (strcmp(pt->class, "")) printf("\"type\": \"%s\", ", pt->class); if (strcmp(pt->class, "")) printf("\"type\": \"%s\", ", pt->class);
if (strcmp(pt->ident, "")) printf("\"ident\": \"%s\", ", pt->ident); if (strcmp(pt->ident, "")) printf("\"ident\": \"%s\", ", pt->ident);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment