github.com/zerosnake0/jzon@v0.0.9-0.20230801092939-1b135cb83f7f/val_decoder_skip.go (about)

     1  package jzon
     2  
     3  import (
     4  	"unsafe"
     5  )
     6  
     7  type emptyObjectDecoder struct{}
     8  
     9  func (*emptyObjectDecoder) Decode(ptr unsafe.Pointer, it *Iterator, _ *DecOpts) error {
    10  	c, err := it.nextToken()
    11  	if err != nil {
    12  		return err
    13  	}
    14  	it.head++
    15  	switch c {
    16  	case 'n':
    17  		return it.expectBytes("ull")
    18  	case '{':
    19  		if it.disallowUnknownFields {
    20  			c, err := it.nextToken()
    21  			if err != nil {
    22  				return err
    23  			}
    24  			it.head++
    25  			if c != '}' {
    26  				return UnexpectedByteError{got: c, exp: '}'}
    27  			}
    28  			return nil
    29  		}
    30  		return skipFunctions[c](it, c)
    31  	default:
    32  		return UnexpectedByteError{got: c, exp: '{', exp2: 'n'}
    33  	}
    34  }