Add method for parsing json object directly

This commit is contained in:
Tobie Morgan Hitchcock 2016-11-14 13:22:43 +00:00
parent cd44c77de6
commit 63e516b63f

View file

@ -170,6 +170,19 @@ func (p *parser) parseArray() ([]interface{}, error) {
} }
func (p *parser) parseObject() (exp map[string]interface{}, err error) {
_, lit, err := p.shouldBe(JSON)
if err != nil {
return nil, &ParseError{Found: lit, Expected: []string{"object"}}
}
val, err := p.declare(JSON, lit)
return val.(map[string]interface{}), err
}
func (p *parser) parseNumber() (int64, error) { func (p *parser) parseNumber() (int64, error) {
_, lit, err := p.shouldBe(NUMBER) _, lit, err := p.shouldBe(NUMBER)