shithub: jget

Download patch

ref: 19232aeaeaa4d7d96176b7dcbab89435f25ab3c6
author: Jean-André Santoni <jean.andre.santoni@gmail.com>
date: Tue Aug 19 04:49:17 EDT 2025

initial commit

--- /dev/null
+++ b/jget.c
@@ -1,0 +1,43 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+#include <json.h>
+
+void
+main(int argc, char **argv)
+{
+	USED(argc, argv);
+
+	Biobuf bin;
+    char *s;
+    JSON *j;
+
+	Binit(&bin, 0, OREAD);
+
+    s = Brdstr(&bin, 0, 1);
+	if(s == nil)
+		sysfatal("could not slurp");
+
+    j = jsonparse(s);
+    if(j == nil)
+        sysfatal("jsonparse failed");
+
+    JSON *output = jsonbyname(j, "output");
+	if(output == nil)
+		sysfatal("no output");
+
+	if(output->t == JSONArray) {
+		JSONEl *first = output->first;
+        JSON *cont = jsonbyname(first->val, "content");
+        if(cont && cont->t == JSONArray) {
+			JSONEl *first = cont->first;
+			JSON *text = jsonbyname(first->val, "text");
+			print("%s\n", jsonstr(text));
+		}
+	}
+
+	free(s);
+	Bterm(&bin);
+
+    exits(nil);
+}
--- /dev/null
+++ b/mkfile
@@ -1,0 +1,8 @@
+</$objtype/mkfile
+
+BIN=/$objtype/bin
+TARG=jget
+OFILES=\
+	jget.$O\
+
+</sys/src/cmd/mkone
\ No newline at end of file
--