Added question Json marshal
This commit is contained in:
parent
c4d6f93c22
commit
1659f7231e
1 changed files with 12 additions and 0 deletions
12
question.go
12
question.go
|
@ -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}
|
||||
|
|
Reference in a new issue