Skip to content

Commit

Permalink
bugfix datastore manipulation helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
pitabwire committed Dec 13, 2023
1 parent 79180d2 commit 3d2b493
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,15 @@ func DBPropertiesToMap(props json.Marshaler) map[string]string {
}

for k, val := range properties {
marVal, err := json.Marshal(val)
if err != nil {

stringVal, ok := val.(string)
if ok {
payload[k] = stringVal
continue
}

marVal, err1 := json.Marshal(val)
if err1 != nil {
continue
}
payload[k] = string(marVal)
Expand All @@ -69,6 +76,12 @@ func DBPropertiesFromMap(propsMap map[string]string) datatypes.JSONMap {
}

for k, val := range propsMap {

if !json.Valid([]byte(val)) {
jsonMap[k] = val
continue
}

var prop interface{}
err := json.Unmarshal([]byte(val), prop)
if err != nil {
Expand Down

0 comments on commit 3d2b493

Please sign in to comment.