Added question Json marshal

This commit is contained in:
Marius Orcsik 2019-12-19 13:34:31 +01:00
parent c4d6f93c22
commit 1659f7231e
No known key found for this signature in database
GPG key ID: 889CE8E4FB2D877A

View file

@ -1,6 +1,7 @@
package activitypub
import (
"bytes"
"errors"
"time"
)
@ -229,6 +230,17 @@ func (q *Question) UnmarshalJSON(data []byte) error {
return nil
}
func (q Question) MarshalJSON() ([]byte, error) {
b := bytes.Buffer{}
b.Write([]byte{'{'})
if !writeQuestion(&b, q) {
return nil, nil
}
b.Write([]byte{'}'})
return b.Bytes(), nil
}
// QuestionNew initializes a Question activity
func QuestionNew(id ID) *Question {
q := Question{ID: id, Type: QuestionType}