Skip to content

Commit 2c75c62

Browse files
committed
Changed object structure
1 parent 71d535f commit 2c75c62

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

microdatago.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
// Parser is an HTML parser that extracts microdata
1717
type Parser struct {
1818
r io.Reader
19-
Microdata map[string]interface{}
19+
Microdata []map[string]interface{}
2020
baseURL *url.URL
2121
}
2222

@@ -34,9 +34,8 @@ func (p *Parser) JSON() ([]byte, error) {
3434
// baseURL is the base URL for resolving relative URLs
3535
func NewParser(r io.Reader, baseURL *url.URL) *Parser {
3636
return &Parser{
37-
r: r,
38-
Microdata: nil,
39-
baseURL: baseURL,
37+
r: r,
38+
baseURL: baseURL,
4039
}
4140
}
4241

@@ -82,10 +81,11 @@ func (p *Parser) Parse() error {
8281
}
8382

8483
// Parsing DOM with microdata to the object
85-
p.Microdata = make(map[string]interface{})
8684
selector = dom.ChildrenFiltered("*")
8785
selector.Each(func(i int, s *goquery.Selection) {
88-
p.extractItem(s, p.Microdata)
86+
item := make(map[string]interface{})
87+
p.extractItem(s, item)
88+
p.Microdata = append(p.Microdata, item)
8989
})
9090

9191
return nil

0 commit comments

Comments
 (0)