Skip to content

Commit

Permalink
Add support for list in annotation field
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Dec 29, 2017
1 parent 7f8da2a commit 279ca9f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion types/mapper/annotation_field.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
type AnnotationField struct {
Field string
Object bool
List bool
IgnoreDefinition bool
}

Expand All @@ -24,6 +25,12 @@ func (e AnnotationField) FromInternal(data map[string]interface{}) {
v = data
}
}
if e.List {
var data []interface{}
if err := json.Unmarshal([]byte(convert.ToString(v)), &data); err == nil {
v = data
}
}

data[e.Field] = v
}
Expand All @@ -32,7 +39,7 @@ func (e AnnotationField) FromInternal(data map[string]interface{}) {
func (e AnnotationField) ToInternal(data map[string]interface{}) {
v, ok := data[e.Field]
if ok {
if e.Object {
if e.Object || e.List {
if bytes, err := json.Marshal(v); err == nil {
v = string(bytes)
}
Expand Down

0 comments on commit 279ca9f

Please sign in to comment.