Skip to content

Commit

Permalink
apis/database: Fix ContentMetadata UnmarshalJSON
Browse files Browse the repository at this point in the history
A string can be stored in json_metadata as well.
  • Loading branch information
tchap committed Sep 20, 2017
1 parent f4bba9c commit 9758023
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apis/database/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (content *Content) IsStory() bool {

type ContentMetadata struct {
Flag bool
Value string
Users []string
Tags []string
Image []string
Expand Down Expand Up @@ -119,8 +120,11 @@ func (metadata *ContentMetadata) UnmarshalJSON(data []byte) error {
}

if len(unquoted) == 0 {
var value ContentMetadata
metadata = &value
return nil
}

if unquoted[0] == '"' {
metadata.Value = unquoted
return nil
}

Expand Down

0 comments on commit 9758023

Please sign in to comment.