From 37d787ce74af18ec187d90c4d4b5f955ba5f75a6 Mon Sep 17 00:00:00 2001 From: Javier Quinones Date: Mon, 17 Aug 2026 10:47:33 -0500 Subject: [PATCH] Script to copy a reference _tag_ field into other json objects, and script to count by unique json field --- addBindings.jq | 23 +++++++++++++++++++++++ countTypes.jq | 4 ++++ 2 files changed, 27 insertions(+) create mode 100644 addBindings.jq create mode 100644 countTypes.jq diff --git a/addBindings.jq b/addBindings.jq new file mode 100644 index 0000000..02e292f --- /dev/null +++ b/addBindings.jq @@ -0,0 +1,23 @@ +. +# Sort first +| walk( + if type == "object" and has("tags") then + .tags |= sort_by(.name) + end +) +# so object positions are predictable +| .tags[3].tags[1].tags as $baseData +| walk( + # Removes .Tags.Controller Tags from the plcName parameter + if type == "object" and has("plcName") then + .plcName.value |= rtrimstr(".Tags.Controller Tags") + elif type == "object" and has("plcname") then + .plcname.value |= rtrimstr(".Tags.Controller Tags") + end +) +# and can be used as the base line to setup the other objects +| walk( + if type == "object" and .name? == "Data" then + .tags = $baseData + end +) \ No newline at end of file diff --git a/countTypes.jq b/countTypes.jq new file mode 100644 index 0000000..7d989f9 --- /dev/null +++ b/countTypes.jq @@ -0,0 +1,4 @@ +. +| .tags +| map(.typeId) +| unique \ No newline at end of file