From 21cd1ee06601a50c542aac93a37b079fb9fe93b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Mon, 21 Aug 2023 15:19:40 +0200 Subject: [PATCH] v0.0.249 better MDTAny json serialization --- exerr/meta.go | 11 ++++++++++- goextVersion.go | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/exerr/meta.go b/exerr/meta.go index c243e0c..87ef8f7 100644 --- a/exerr/meta.go +++ b/exerr/meta.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/gin-gonic/gin" "github.com/rs/zerolog" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" @@ -612,7 +613,15 @@ func (v MetaValue) rawValueForJson() any { if v.Value.(AnyWrap).IsNil { return nil } - return v.Value.(AnyWrap).Serialize() + if v.Value.(AnyWrap).IsError { + return bson.M{"@error": true} + } + jsonobj := gin.H{} + if err := json.Unmarshal([]byte(v.Value.(AnyWrap).Json), &jsonobj); err == nil { + return jsonobj + } else { + return bson.M{"type": v.Value.(AnyWrap).Type, "data": v.Value.(AnyWrap).Json} + } } if v.DataType == MDTID { if v.Value.(IDWrap).IsNil { diff --git a/goextVersion.go b/goextVersion.go index 01536da..884660c 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.248" +const GoextVersion = "0.0.249" -const GoextVersionTimestamp = "2023-08-21T15:08:35+0200" +const GoextVersionTimestamp = "2023-08-21T15:19:40+0200"