package decoder

import (
	
	
	
	

	
	
)

type unmarshalJSONDecoder struct {
	typ        *runtime.Type
	structName string
	fieldName  string
}

func newUnmarshalJSONDecoder( *runtime.Type, ,  string) *unmarshalJSONDecoder {
	return &unmarshalJSONDecoder{
		typ:        ,
		structName: ,
		fieldName:  ,
	}
}

func ( *unmarshalJSONDecoder) ( int64,  error) {
	switch e := .(type) {
	case *errors.UnmarshalTypeError:
		.Struct = .structName
		.Field = .fieldName
	case *errors.SyntaxError:
		.Offset = 
	}
}

func ( *unmarshalJSONDecoder) ( *Stream,  int64,  unsafe.Pointer) error {
	.skipWhiteSpace()
	 := .cursor
	if  := .skipValue();  != nil {
		return 
	}
	 := .buf[:.cursor]
	 := make([]byte, len())
	copy(, )

	 := *(*interface{})(unsafe.Pointer(&emptyInterface{
		typ: .typ,
		ptr: ,
	}))
	switch v := .(type) {
	case unmarshalerContext:
		var  context.Context
		if (.Option.Flags & ContextOption) != 0 {
			 = .Option.Context
		} else {
			 = context.Background()
		}
		if  := .UnmarshalJSON(, );  != nil {
			.annotateError(.cursor, )
			return 
		}
	case json.Unmarshaler:
		if  := .UnmarshalJSON();  != nil {
			.annotateError(.cursor, )
			return 
		}
	}
	return nil
}

func ( *unmarshalJSONDecoder) ( *RuntimeContext, ,  int64,  unsafe.Pointer) (int64, error) {
	 := .Buf
	 = skipWhiteSpace(, )
	 := 
	,  := skipValue(, , )
	if  != nil {
		return 0, 
	}
	 := [:]
	 := make([]byte, len())
	copy(, )

	 := *(*interface{})(unsafe.Pointer(&emptyInterface{
		typ: .typ,
		ptr: ,
	}))
	if (.Option.Flags & ContextOption) != 0 {
		if  := .(unmarshalerContext).UnmarshalJSON(.Option.Context, );  != nil {
			.annotateError(, )
			return 0, 
		}
	} else {
		if  := .(json.Unmarshaler).UnmarshalJSON();  != nil {
			.annotateError(, )
			return 0, 
		}
	}
	return , nil
}

func ( *unmarshalJSONDecoder) ( *RuntimeContext, ,  int64) ([][]byte, int64, error) {
	return nil, 0, fmt.Errorf("json: unmarshal json decoder does not support decode path")
}