main/task_sdcard.c

changeset 87
47253f294a9f
parent 64
326c38d3681b
child 88
7f02dbee58d0
--- a/main/task_sdcard.c	Sun Jun 07 22:30:07 2020 +0200
+++ b/main/task_sdcard.c	Wed Jun 10 09:43:51 2020 +0200
@@ -133,11 +133,7 @@
 	    f = fopen(filename, "a");
 	    if (f) {
 		strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
-		fprintf(f, "{\n");
-		fprintf(f, " \"brew\": [{\n");
-		fprintf(f, "  \"Recipe\":\"%s %s\",\n", recipe.Code, recipe.Name);
-		fprintf(f, "  \"Date\":\"%s\",\n", strftime_buf);
-		fprintf(f, "  \"brewdata\":[\n");
+		fprintf(f, "{\"brew\":[{\"Recipe\":\"%s %s\",\"Date\":\"%s\",\"brewdata\":[\n", recipe.Code, recipe.Name, strftime_buf);
 		addcomma = false;
 		fclose(f);
 	    } else {
@@ -522,8 +518,7 @@
 		    // First close the JSON data records
 		    FILE *f = fopen(filename, "a+");
 		    if (f) {
-			fprintf(f, "  ],\n");	// End of brewdata
-			fprintf(f, "  \"annotations\":[\n");
+			fprintf(f, "],\"annotations\":[\n");	// End of brewdata
 			// Insert annotation records
 			sprintf(destname, "/spiffs/log/%s.anno", sdcard_state->logfile);
 			FILE *a = fopen(destname, "r");
@@ -539,9 +534,7 @@
 			    fclose(a);
 			    unlink(destname);
 			}
-			fprintf(f, "  ]\n");	// End of annotations
-			fprintf(f, " }]\n");	// End of brew
-			fprintf(f, "}\n");
+			fprintf(f, "]}]}\n");	// End of annotations and brew
 			fclose(f);
 		    }
 		    sprintf(destname, "/sdcard/w/log/%s.json", sdcard_state->logfile);

mercurial