Skip to content

Commit

Permalink
fix marshalling for maps
Browse files Browse the repository at this point in the history
  • Loading branch information
imperfect-fourth committed Jun 11, 2024
1 parent 8696a2c commit 00e87fd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions eywa.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ func (f RawField) GetValue() string {
return val.marshalGQL()
}
val, _ := json.Marshal(f.Value)
if vt := reflect.TypeOf(f.Value); vt.Kind() == reflect.Ptr {
if vt.Elem().Kind() == reflect.Struct {
val, _ = json.Marshal(string(val))
}
} else if vt.Kind() == reflect.Struct {
vt := reflect.TypeOf(f.Value)
if vt.Kind() == reflect.Ptr {
vt = vt.Elem()
}
if vt.Kind() == reflect.Struct || vt.Kind() == reflect.Map {
val, _ = json.Marshal(string(val))
}
return string(val)
Expand All @@ -81,11 +81,11 @@ func (f ModelField[M]) GetValue() string {
}

val, _ := json.Marshal(f.Value)
if vt := reflect.TypeOf(f.Value); vt.Kind() == reflect.Ptr {
if vt.Elem().Kind() == reflect.Struct {
val, _ = json.Marshal(string(val))
}
} else if vt.Kind() == reflect.Struct {
vt := reflect.TypeOf(f.Value)
if vt.Kind() == reflect.Ptr {
vt = vt.Elem()
}
if vt.Kind() == reflect.Struct || vt.Kind() == reflect.Map {
val, _ = json.Marshal(string(val))
}
return string(val)
Expand Down

0 comments on commit 00e87fd

Please sign in to comment.