-
Notifications
You must be signed in to change notification settings - Fork 3
/
question.go
52 lines (45 loc) · 1.29 KB
/
question.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package leetgode
import (
"encoding/json"
"strconv"
)
type GetQuestionDetailResult struct {
Data QdrData `json:"data"`
}
type QdrData struct {
IsCurrentUserAuthenticated bool `json:"isCurrentUserAuthenticated"`
Question Question `json:"question"`
}
type Question struct {
Slug string `json:"-"`
Referer string `json:"-"`
FrontendQuestionID int `json:"-"`
QuestionID string `json:"questionId"`
Content string `json:"content"`
Stats string `json:"stats"`
CodeDefinition Codes `json:"codeDefinition"`
SampleTestCase string `json:"sampleTestCase"`
EnableRunCode bool `json:"enableRunCode"`
MetaData string `json:"metaData"`
TranslatedContent interface{} `json:"translatedContent"`
}
// Code the struct of leetcode codes.
type Code struct {
Text string `json:"text"`
Value string `json:"value"`
DefaultCode string `json:"defaultCode"`
}
// Codes the slice of Code
type Codes []*Code
func (c *Codes) UnmarshalJSON(b []byte) error {
var cs []*Code
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
if err := json.Unmarshal([]byte(s), &cs); err != nil {
return err
}
*c = append(*c, cs...)
return nil
}