func (r *jsonReader) ignoreNext() (raw []byte, err error) {
	r.skipWS()
	snapshot := r.Snapshot()
	before := r.Len()
	entity, _, err := r.step()
	if err != nil {
		return nil, err
	}
	switch entity {
	case arrStart:
		err = ignoreKind(r, arrEnd)
	case dictStart:
		err = ignoreKind(r, dictEnd)
	default:
	}
	if err != nil {
		return nil, err
	}
	after := r.Len()
	r.Restore(snapshot)
	bytes, _ := r.Collect(before - after)
	return bytes, nil
}
ignore type of next element and return raw content.
package elasticsearch
import (
	"errors"
	"github.com/elastic/beats/libbeat/common/streambuf"
)
type jsonReader struct {
	streambuf.Buffer
	states       []state  
	currentState state
	statesBuf [32]state
}
var (
	errFailing             = errors.New("JSON parser failed")
	errUnknownChar         = errors.New("unknown character")
	errQuoteMissing        = errors.New("missing closing quote")
	errExpectColon         = errors.New("expected ':' after map key")
	errUnexpectedDictClose = errors.New("unexpected '}'")
	errUnexpectedArrClose  = errors.New("unexpected ']'")
	errExpectedDigit       = errors.New("expected a digit")
	errExpectedObject      = errors.New("expected JSON object")
	errExpectedArray       = errors.New("expected JSON array")
	errExpectedFieldName   = errors.New("expected JSON object field name")
	errExpectedInteger     = errors.New("expected integer value")
	errExpectedNull        = errors.New("expected null value")
	errExpectedFalse       = errors.New("expected false value")
	errExpectedTrue        = errors.New("expected true value")
	errExpectedArrayField  = errors.New("expected ']' or ','")
)
var (
	nullSymbol  = []byte("null")
	trueSymbol  = []byte("true")
	falseSymbol = []byte("false")
)
type entity uint8
const (
	failEntity entity = iota
	trueValue
	falseValue
	nullValue
	dictStart
	dictEnd
	arrStart
	arrEnd
	stringEntity
	mapKeyEntity
	intEntity
	doubleEntity
)
type state uint8
const (
	failedState state = iota
	startState
	arrState
	arrStateNext
	dictState
	dictFieldState
	dictFieldStateEnd
)
var entityNames = map[entity]string{
	failEntity:   "failEntity",
	trueValue:    "trueValue",
	falseValue:   "falseValue",
	nullValue:    "nullValue",
	dictStart:    "dictStart",
	dictEnd:      "dictEnd",
	arrStart:     "arrStart",
	arrEnd:       "arrEnd",
	stringEntity: "stringEntity",
	mapKeyEntity: "mapKeyEntity",
	intEntity:    "intEntity",
	doubleEntity: "doubleEntity",
}
var stateNames = map[state]string{
	failedState:       "failed",
	startState:        "start",
	arrState:          "array",
	arrStateNext:      "arrayNext",
	dictState:         "dict",
	dictFieldState:    "dictValue",
	dictFieldStateEnd: "dictNext",
}
func (e entity) String() string {
	if name, ok := entityNames[e]; ok {
		return name
	}
	return "unknown"
}
func (s state) String() string {
	if name, ok := stateNames[s]; ok {
		return name
	}
	return "unknown"
}
func newJSONReader(in []byte) *jsonReader {
	r := &jsonReader{}
	r.init(in)
	return r
}
func (r *jsonReader) init(in []byte) {
	r.Buffer.Init(in, true)
	r.currentState = startState
	r.states = r.statesBuf[:0]
}
var whitespace = []byte(" \t\r\n")
func (r *jsonReader) skipWS() {
	r.IgnoreSymbols(whitespace)
}
func (r *jsonReader) pushState(next state) {
	if r.currentState != failedState {
		r.states = append(r.states, r.currentState)
	}
	r.currentState = next
}
func (r *jsonReader) popState() {
	if len(r.states) == 0 {
		r.currentState = failedState
	} else {
		last := len(r.states) - 1
		r.currentState = r.states[last]
		r.states = r.states[:last]
	}
}
func (r *jsonReader) expectDict() error {
	entity, _, err := r.step()
	if err != nil {
		return err
	}
	if entity != dictStart {
		return r.SetError(errExpectedObject)
	}
	return nil
}
func (r *jsonReader) expectArray() error {
	entity, _, err := r.step()
	if err != nil {
		return err
	}
	if entity != arrStart {
		return r.SetError(errExpectedArray)
	}
	return nil
}
func (r *jsonReader) nextFieldName() (entity, []byte, error) {
	entity, raw, err := r.step()
	if err != nil {
		return entity, raw, err
	}
	if entity != mapKeyEntity && entity != dictEnd {
		return entity, nil, r.SetError(errExpectedFieldName)
	}
	return entity, raw, err
}
func (r *jsonReader) nextInt() (int, error) {
	entity, raw, err := r.step()
	if err != nil {
		return 0, err
	}
	if entity != intEntity {
		return 0, errExpectedInteger
	}
	tmp := streambuf.NewFixed(raw)
	i, err := tmp.AsciiInt(false)
	return int(i), err
}