NOISSUE - Add case for a single SenML value

Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>
This commit is contained in:
Dusan Borovcanin
2025-04-16 00:20:53 +02:00
parent 08d727bf6e
commit 8c3b3229a8
+5
View File
@@ -16,10 +16,15 @@ func (re *re) save(ctx context.Context, original *messaging.Message) lua.LGFunct
return func(l *lua.LState) int {
table := l.ToTable(1)
val := convertLua(table)
// In case there is a single SenML value, convert to slice so we can unmarshal.
if _, ok := val.([]any); !ok {
val = []any{val}
}
data, err := json.Marshal(val)
if err != nil {
return 0
}
var message []senml.Message
if err := json.Unmarshal(data, &message); err != nil {
return 0