[PATCH 4/4] jshn.sh: Add anonymous strings in arrays
Philip Prindeville
philipp at redfish-solutions.com
Sun May 4 14:56:46 PDT 2025
From: Philip Prindeville <philipp at redfish-solutions.com>
Add convenience function to add anonymous strings to arrays.
---
sh/jshn.sh | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/sh/jshn.sh b/sh/jshn.sh
index c10ff3f154353c9a39b6b8ea9646464211450d86..d961926d3bc72c842bb841220bfd17d429d2fc6c 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