From 72e8b79ed698019dbcb6527e57e983e9af5aa89a Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Fri, 3 Oct 2025 12:39:01 -0600 Subject: [PATCH] Fix AbstractEvent#payload for non-JSON payloads Payloads are not guaranteed to be JSON, so if they aren't just return it directly. Signed-off-by: Cody Cutrer --- lib/openhab/core/events/abstract_event.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/openhab/core/events/abstract_event.rb b/lib/openhab/core/events/abstract_event.rb index 3795aab958..feb5ddfd08 100644 --- a/lib/openhab/core/events/abstract_event.rb +++ b/lib/openhab/core/events/abstract_event.rb @@ -39,7 +39,7 @@ def inputs=(value) # # Returns the event payload as a Hash. # - # @return [Hash, nil] The payload object parsed by JSON. The keys are symbolized. + # @return [Hash, String, nil] The payload object parsed by JSON. The keys are symbolized. # `nil` when the payload is empty. # def payload @@ -48,6 +48,8 @@ def payload original_verbose = $VERBOSE $VERBOSE = nil @payload ||= JSON.parse(get_payload, symbolize_names: true) unless get_payload.empty? + rescue JSON::ParserError + get_payload ensure $VERBOSE = original_verbose end