[PATCH 3/3] jshn.sh: Add anonymous strings in arrays

Philip Prindeville philipp at redfish-solutions.com
Sun Aug 3 13:31:09 PDT 2025


From: Philip Prindeville <philipp at redfish-solutions.com>

---
 sh/jshn.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sh/jshn.sh b/sh/jshn.sh
index e9c6a033981a1e877cf8de3a330b640e5094bf99..75faf8245841a0ba766548e79a14c8a24eceed24 100644
--- a/sh/jshn.sh
+++ b/sh/jshn.sh
@@ -150,6 +150,17 @@ json_add_string() {
 	_json_add_generic string "$1" "$2" "$cur"
 }
 
+json_push_string() {
+	local cur
+	_json_get_var cur JSON_CUR
+	[ "${cur%%[0-9]*}" = "J_A" ] || {
+		[ -n "$_json_no_warning" ] || \
+			echo "WARNING: Not in an array" >&2
+		return 1
+	}
+	_json_add_generic string "" "$2" "$cur"
+}
+
 json_add_int() {
 	local cur
 	_json_get_var cur JSON_CUR
-- 
2.43.0




More information about the openwrt-devel mailing list