-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjson.go
More file actions
40 lines (35 loc) · 1004 Bytes
/
json.go
File metadata and controls
40 lines (35 loc) · 1004 Bytes
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
package main
import "encoding/json"
func unmarshalSearchStruct(data []byte) ([]interface{}, error) {
var a []SearchStructElement
err := json.Unmarshal(data, &a)
b := make([]interface{}, len(a))
for i := range a {
b[i] = a[i]
}
return b, err
}
// SearchStructElement is one element in the search structure generated by DartDoc
type SearchStructElement struct {
Name string `json:"name"`
QualifiedName string `json:"qualifiedName"`
Href string `json:"href"`
Type string `json:"type"`
OverriddenDepth int64 `json:"overriddenDepth"`
EnclosedBy *struct {
Name string `json:"name"`
Type string `json:"type"`
} `json:"enclosedBy,omitempty"`
}
func unmarshalPubSearch(data []byte) (PubSearch, error) {
var r PubSearch
err := json.Unmarshal(data, &r)
return r, err
}
// PubSearch are the search results from pub.dev
type PubSearch struct {
Packages []struct {
Package string `json:"package"`
} `json:"packages"`
Next string `json:"next"`
}