shithub: json2awk

Download patch

ref: f8d74ea182246209e30cb5e90e7697a5ad99a407
parent: 45c9730c403606806969a273b8032dd305cc83df
author: Aidan Wiggins <akw@oneiri.one>
date: Thu Mar 26 22:37:17 EDT 2026

handle empty input and fmt output of example

--- a/json2awk.c
+++ b/json2awk.c
@@ -132,7 +132,8 @@
 	/* read it all into j */
 	fmtinstall('L', Lfmt);
 	b = Bfdopen(fd, OREAD);
-	j = Brdstr(b, '\0', '\0');
+	if((j = Brdstr(b, '\0', '\0')) == nil)
+		exits(0);
 	if((J = jsonparse(j)) == nil)
 		sysfatal("jsonparse: %r");
 
--- a/weather.rc
+++ b/weather.rc
@@ -46,4 +46,4 @@
 		print when
 		print "\t" json["properties", "periods", i, "detailedForecast"]
 	}
-'
+' | fmt
--