From 8331c4b305e112b62e327f7726022f2605d22b5c Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Sun, 9 Feb 2025 05:32:30 +0000 Subject: [PATCH] Add Exists function --- internal/glance/widget-custom-api.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/glance/widget-custom-api.go b/internal/glance/widget-custom-api.go index 04211c6..c8e3773 100644 --- a/internal/glance/widget-custom-api.go +++ b/internal/glance/widget-custom-api.go @@ -133,6 +133,10 @@ func gJsonResultArrayToDecoratedResultArray(results []gjson.Result) []decoratedG return decoratedResults } +func (r *decoratedGJSONResult) Exists(key string) bool { + return r.Get(key).Exists() +} + func (r *decoratedGJSONResult) Array(key string) []decoratedGJSONResult { if key == "" { return gJsonResultArrayToDecoratedResultArray(r.Result.Array())