v0.0.249 better MDTAny json serialization
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 54s

This commit is contained in:
Mike Schwörer 2023-08-21 15:19:40 +02:00
parent ae43cbb623
commit 21cd1ee066
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 12 additions and 3 deletions

View File

@ -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 {

View File

@ -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"