Source file src/encoding/json/decode.go

     1  // Copyright 2010 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Represents JSON data structure using native Go types: booleans, floats,
     6  // strings, arrays, and maps.
     7  
     8  //go:build !goexperiment.jsonv2
     9  
    10  package json
    11  
    12  import (
    13  	"encoding"
    14  	"encoding/base64"
    15  	"fmt"
    16  	"reflect"
    17  	"strconv"
    18  	"strings"
    19  	"unicode"
    20  	"unicode/utf16"
    21  	"unicode/utf8"
    22  )
    23  
    24  // Unmarshal parses the JSON-encoded data and stores the result
    25  // in the value pointed to by v. If v is nil or not a pointer,
    26  // Unmarshal returns an [InvalidUnmarshalError].
    27  //
    28  // Unmarshal uses the inverse of the encodings that
    29  // [Marshal] uses, allocating maps, slices, and pointers as necessary,
    30  // with the following additional rules:
    31  //
    32  // To unmarshal JSON into a pointer, Unmarshal first handles the case of
    33  // the JSON being the JSON literal null. In that case, Unmarshal sets
    34  // the pointer to nil. Otherwise, Unmarshal unmarshals the JSON into
    35  // the value pointed at by the pointer. If the pointer is nil, Unmarshal
    36  // allocates a new value for it to point to.
    37  //
    38  // To unmarshal JSON into a value implementing [Unmarshaler],
    39  // Unmarshal calls that value's [Unmarshaler.UnmarshalJSON] method, including
    40  // when the input is a JSON null.
    41  // Otherwise, if the value implements [encoding.TextUnmarshaler]
    42  // and the input is a JSON quoted string, Unmarshal calls
    43  // [encoding.TextUnmarshaler.UnmarshalText] with the unquoted form of the string.
    44  //
    45  // To unmarshal JSON into a struct, Unmarshal matches incoming object keys to
    46  // the keys used by [Marshal] (either the struct field name or its tag),
    47  // ignoring case. If multiple struct fields match an object key, an exact case
    48  // match is preferred over a case-insensitive one.
    49  //
    50  // Incoming object members are processed in the order observed. If an object
    51  // includes duplicate keys, later duplicates will replace or be merged into
    52  // prior values.
    53  //
    54  // To unmarshal JSON into an interface value,
    55  // Unmarshal stores one of these in the interface value:
    56  //
    57  //   - bool, for JSON booleans
    58  //   - float64, for JSON numbers
    59  //   - string, for JSON strings
    60  //   - []any, for JSON arrays
    61  //   - map[string]any, for JSON objects
    62  //   - nil for JSON null
    63  //
    64  // To unmarshal a JSON array into a slice, Unmarshal decodes each JSON array
    65  // element into the corresponding slice element, reusing existing slice
    66  // elements in-place. The slice grows to accommodate additional elements,
    67  // or is truncated if the JSON array is shorter.
    68  // As a special case, to unmarshal an empty JSON array into a slice,
    69  // Unmarshal replaces the slice with a new empty slice.
    70  //
    71  // To unmarshal a JSON array into a Go array, Unmarshal decodes
    72  // JSON array elements into corresponding Go array elements.
    73  // If the Go array is smaller than the JSON array,
    74  // the additional JSON array elements are discarded.
    75  // If the JSON array is smaller than the Go array,
    76  // the additional Go array elements are set to zero values.
    77  //
    78  // To unmarshal a JSON object into a map, Unmarshal first establishes a map to
    79  // use. If the map is nil, Unmarshal allocates a new map. Otherwise Unmarshal
    80  // reuses the existing map, keeping existing entries. Unmarshal then stores
    81  // key-value pairs from the JSON object into the map. The map's key type must
    82  // either be any string type, an integer, or implement [encoding.TextUnmarshaler].
    83  //
    84  // If the JSON-encoded data contain a syntax error, Unmarshal returns a [SyntaxError].
    85  //
    86  // If a JSON value is not appropriate for a given target type,
    87  // or if a JSON number overflows the target type, Unmarshal
    88  // skips that field and completes the unmarshaling as best it can.
    89  // If no more serious errors are encountered, Unmarshal returns
    90  // an [UnmarshalTypeError] describing the earliest such error. In any
    91  // case, it's not guaranteed that all the remaining fields following
    92  // the problematic one will be unmarshaled into the target object.
    93  //
    94  // The JSON null value unmarshals into an interface, map, pointer, or slice
    95  // by setting that Go value to nil. Because null is often used in JSON to mean
    96  // “not present,” unmarshaling a JSON null into any other Go type has no effect
    97  // on the value and produces no error.
    98  //
    99  // When unmarshaling quoted strings, invalid UTF-8 or
   100  // invalid UTF-16 surrogate pairs are not treated as an error.
   101  // Instead, they are replaced by the Unicode replacement
   102  // character U+FFFD.
   103  func Unmarshal(data []byte, v any) error {
   104  	// Check for well-formedness.
   105  	// Avoids filling out half a data structure
   106  	// before discovering a JSON syntax error.
   107  	var d decodeState
   108  	err := checkValid(data, &d.scan)
   109  	if err != nil {
   110  		return err
   111  	}
   112  
   113  	d.init(data)
   114  	return d.unmarshal(v)
   115  }
   116  
   117  // Unmarshaler is the interface implemented by types
   118  // that can unmarshal a JSON description of themselves.
   119  // The input can be assumed to be a valid encoding of
   120  // a JSON value. UnmarshalJSON must copy the JSON data
   121  // if it wishes to retain the data after returning.
   122  type Unmarshaler interface {
   123  	UnmarshalJSON([]byte) error
   124  }
   125  
   126  // An UnmarshalTypeError describes a JSON value that was
   127  // not appropriate for a value of a specific Go type.
   128  type UnmarshalTypeError struct {
   129  	Value  string       // description of JSON value - "bool", "array", "number -5"
   130  	Type   reflect.Type // type of Go value it could not be assigned to
   131  	Offset int64        // error occurred after reading Offset bytes
   132  	Struct string       // name of the struct type containing the field
   133  	Field  string       // the full path from root node to the field, include embedded struct
   134  }
   135  
   136  func (e *UnmarshalTypeError) Error() string {
   137  	if e.Struct != "" || e.Field != "" {
   138  		return "json: cannot unmarshal " + e.Value + " into Go struct field " + e.Struct + "." + e.Field + " of type " + e.Type.String()
   139  	}
   140  	return "json: cannot unmarshal " + e.Value + " into Go value of type " + e.Type.String()
   141  }
   142  
   143  // An UnmarshalFieldError describes a JSON object key that
   144  // led to an unexported (and therefore unwritable) struct field.
   145  //
   146  // Deprecated: No longer used; kept for compatibility.
   147  type UnmarshalFieldError struct {
   148  	Key   string
   149  	Type  reflect.Type
   150  	Field reflect.StructField
   151  }
   152  
   153  func (e *UnmarshalFieldError) Error() string {
   154  	return "json: cannot unmarshal object key " + strconv.Quote(e.Key) + " into unexported field " + e.Field.Name + " of type " + e.Type.String()
   155  }
   156  
   157  // An InvalidUnmarshalError describes an invalid argument passed to [Unmarshal].
   158  // (The argument to [Unmarshal] must be a non-nil pointer.)
   159  type InvalidUnmarshalError struct {
   160  	Type reflect.Type
   161  }
   162  
   163  func (e *InvalidUnmarshalError) Error() string {
   164  	if e.Type == nil {
   165  		return "json: Unmarshal(nil)"
   166  	}
   167  
   168  	if e.Type.Kind() != reflect.Pointer {
   169  		return "json: Unmarshal(non-pointer " + e.Type.String() + ")"
   170  	}
   171  	return "json: Unmarshal(nil " + e.Type.String() + ")"
   172  }
   173  
   174  func (d *decodeState) unmarshal(v any) error {
   175  	rv := reflect.ValueOf(v)
   176  	if rv.Kind() != reflect.Pointer || rv.IsNil() {
   177  		return &InvalidUnmarshalError{reflect.TypeOf(v)}
   178  	}
   179  
   180  	d.scan.reset()
   181  	d.scanWhile(scanSkipSpace)
   182  	// We decode rv not rv.Elem because the Unmarshaler interface
   183  	// test must be applied at the top level of the value.
   184  	err := d.value(rv)
   185  	if err != nil {
   186  		return d.addErrorContext(err)
   187  	}
   188  	return d.savedError
   189  }
   190  
   191  // A Number represents a JSON number literal.
   192  type Number string
   193  
   194  // String returns the literal text of the number.
   195  func (n Number) String() string { return string(n) }
   196  
   197  // Float64 returns the number as a float64.
   198  func (n Number) Float64() (float64, error) {
   199  	return strconv.ParseFloat(string(n), 64)
   200  }
   201  
   202  // Int64 returns the number as an int64.
   203  func (n Number) Int64() (int64, error) {
   204  	return strconv.ParseInt(string(n), 10, 64)
   205  }
   206  
   207  // An errorContext provides context for type errors during decoding.
   208  type errorContext struct {
   209  	Struct     reflect.Type
   210  	FieldStack []string
   211  }
   212  
   213  // decodeState represents the state while decoding a JSON value.
   214  type decodeState struct {
   215  	data                  []byte
   216  	off                   int // next read offset in data
   217  	opcode                int // last read result
   218  	scan                  scanner
   219  	errorContext          *errorContext
   220  	savedError            error
   221  	useNumber             bool
   222  	disallowUnknownFields bool
   223  }
   224  
   225  // readIndex returns the position of the last byte read.
   226  func (d *decodeState) readIndex() int {
   227  	return d.off - 1
   228  }
   229  
   230  // phasePanicMsg is used as a panic message when we end up with something that
   231  // shouldn't happen. It can indicate a bug in the JSON decoder, or that
   232  // something is editing the data slice while the decoder executes.
   233  const phasePanicMsg = "JSON decoder out of sync - data changing underfoot?"
   234  
   235  func (d *decodeState) init(data []byte) *decodeState {
   236  	d.data = data
   237  	d.off = 0
   238  	d.savedError = nil
   239  	if d.errorContext != nil {
   240  		d.errorContext.Struct = nil
   241  		// Reuse the allocated space for the FieldStack slice.
   242  		d.errorContext.FieldStack = d.errorContext.FieldStack[:0]
   243  	}
   244  	return d
   245  }
   246  
   247  // saveError saves the first err it is called with,
   248  // for reporting at the end of the unmarshal.
   249  func (d *decodeState) saveError(err error) {
   250  	if d.savedError == nil {
   251  		d.savedError = d.addErrorContext(err)
   252  	}
   253  }
   254  
   255  // addErrorContext returns a new error enhanced with information from d.errorContext
   256  func (d *decodeState) addErrorContext(err error) error {
   257  	if d.errorContext != nil && (d.errorContext.Struct != nil || len(d.errorContext.FieldStack) > 0) {
   258  		switch err := err.(type) {
   259  		case *UnmarshalTypeError:
   260  			err.Struct = d.errorContext.Struct.Name()
   261  			fieldStack := d.errorContext.FieldStack
   262  			if err.Field != "" {
   263  				fieldStack = append(fieldStack, err.Field)
   264  			}
   265  			err.Field = strings.Join(fieldStack, ".")
   266  		}
   267  	}
   268  	return err
   269  }
   270  
   271  // skip scans to the end of what was started.
   272  func (d *decodeState) skip() {
   273  	s, data, i := &d.scan, d.data, d.off
   274  	depth := len(s.parseState)
   275  	for {
   276  		op := s.step(s, data[i])
   277  		i++
   278  		if len(s.parseState) < depth {
   279  			d.off = i
   280  			d.opcode = op
   281  			return
   282  		}
   283  	}
   284  }
   285  
   286  // scanNext processes the byte at d.data[d.off].
   287  func (d *decodeState) scanNext() {
   288  	if d.off < len(d.data) {
   289  		d.opcode = d.scan.step(&d.scan, d.data[d.off])
   290  		d.off++
   291  	} else {
   292  		d.opcode = d.scan.eof()
   293  		d.off = len(d.data) + 1 // mark processed EOF with len+1
   294  	}
   295  }
   296  
   297  // scanWhile processes bytes in d.data[d.off:] until it
   298  // receives a scan code not equal to op.
   299  func (d *decodeState) scanWhile(op int) {
   300  	s, data, i := &d.scan, d.data, d.off
   301  	for i < len(data) {
   302  		newOp := s.step(s, data[i])
   303  		i++
   304  		if newOp != op {
   305  			d.opcode = newOp
   306  			d.off = i
   307  			return
   308  		}
   309  	}
   310  
   311  	d.off = len(data) + 1 // mark processed EOF with len+1
   312  	d.opcode = d.scan.eof()
   313  }
   314  
   315  // rescanLiteral is similar to scanWhile(scanContinue), but it specialises the
   316  // common case where we're decoding a literal. The decoder scans the input
   317  // twice, once for syntax errors and to check the length of the value, and the
   318  // second to perform the decoding.
   319  //
   320  // Only in the second step do we use decodeState to tokenize literals, so we
   321  // know there aren't any syntax errors. We can take advantage of that knowledge,
   322  // and scan a literal's bytes much more quickly.
   323  func (d *decodeState) rescanLiteral() {
   324  	data, i := d.data, d.off
   325  Switch:
   326  	switch data[i-1] {
   327  	case '"': // string
   328  		for ; i < len(data); i++ {
   329  			switch data[i] {
   330  			case '\\':
   331  				i++ // escaped char
   332  			case '"':
   333  				i++ // tokenize the closing quote too
   334  				break Switch
   335  			}
   336  		}
   337  	case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-': // number
   338  		for ; i < len(data); i++ {
   339  			switch data[i] {
   340  			case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
   341  				'.', 'e', 'E', '+', '-':
   342  			default:
   343  				break Switch
   344  			}
   345  		}
   346  	case 't': // true
   347  		i += len("rue")
   348  	case 'f': // false
   349  		i += len("alse")
   350  	case 'n': // null
   351  		i += len("ull")
   352  	}
   353  	if i < len(data) {
   354  		d.opcode = stateEndValue(&d.scan, data[i])
   355  	} else {
   356  		d.opcode = scanEnd
   357  	}
   358  	d.off = i + 1
   359  }
   360  
   361  // value consumes a JSON value from d.data[d.off-1:], decoding into v, and
   362  // reads the following byte ahead. If v is invalid, the value is discarded.
   363  // The first byte of the value has been read already.
   364  func (d *decodeState) value(v reflect.Value) error {
   365  	switch d.opcode {
   366  	default:
   367  		panic(phasePanicMsg)
   368  
   369  	case scanBeginArray:
   370  		if v.IsValid() {
   371  			if err := d.array(v); err != nil {
   372  				return err
   373  			}
   374  		} else {
   375  			d.skip()
   376  		}
   377  		d.scanNext()
   378  
   379  	case scanBeginObject:
   380  		if v.IsValid() {
   381  			if err := d.object(v); err != nil {
   382  				return err
   383  			}
   384  		} else {
   385  			d.skip()
   386  		}
   387  		d.scanNext()
   388  
   389  	case scanBeginLiteral:
   390  		// All bytes inside literal return scanContinue op code.
   391  		start := d.readIndex()
   392  		d.rescanLiteral()
   393  
   394  		if v.IsValid() {
   395  			if err := d.literalStore(d.data[start:d.readIndex()], v, false); err != nil {
   396  				return err
   397  			}
   398  		}
   399  	}
   400  	return nil
   401  }
   402  
   403  type unquotedValue struct{}
   404  
   405  // valueQuoted is like value but decodes a
   406  // quoted string literal or literal null into an interface value.
   407  // If it finds anything other than a quoted string literal or null,
   408  // valueQuoted returns unquotedValue{}.
   409  func (d *decodeState) valueQuoted() any {
   410  	switch d.opcode {
   411  	default:
   412  		panic(phasePanicMsg)
   413  
   414  	case scanBeginArray, scanBeginObject:
   415  		d.skip()
   416  		d.scanNext()
   417  
   418  	case scanBeginLiteral:
   419  		v := d.literalInterface()
   420  		switch v.(type) {
   421  		case nil, string:
   422  			return v
   423  		}
   424  	}
   425  	return unquotedValue{}
   426  }
   427  
   428  // indirect walks down v allocating pointers as needed,
   429  // until it gets to a non-pointer.
   430  // If it encounters an Unmarshaler, indirect stops and returns that.
   431  // If decodingNull is true, indirect stops at the first settable pointer so it
   432  // can be set to nil.
   433  func indirect(v reflect.Value, decodingNull bool) (Unmarshaler, encoding.TextUnmarshaler, reflect.Value) {
   434  	// Issue #24153 indicates that it is generally not a guaranteed property
   435  	// that you may round-trip a reflect.Value by calling Value.Addr().Elem()
   436  	// and expect the value to still be settable for values derived from
   437  	// unexported embedded struct fields.
   438  	//
   439  	// The logic below effectively does this when it first addresses the value
   440  	// (to satisfy possible pointer methods) and continues to dereference
   441  	// subsequent pointers as necessary.
   442  	//
   443  	// After the first round-trip, we set v back to the original value to
   444  	// preserve the original RW flags contained in reflect.Value.
   445  	v0 := v
   446  	haveAddr := false
   447  
   448  	// If v is a named type and is addressable,
   449  	// start with its address, so that if the type has pointer methods,
   450  	// we find them.
   451  	if v.Kind() != reflect.Pointer && v.Type().Name() != "" && v.CanAddr() {
   452  		haveAddr = true
   453  		v = v.Addr()
   454  	}
   455  	for {
   456  		// Load value from interface, but only if the result will be
   457  		// usefully addressable.
   458  		if v.Kind() == reflect.Interface && !v.IsNil() {
   459  			e := v.Elem()
   460  			if e.Kind() == reflect.Pointer && !e.IsNil() && (!decodingNull || e.Elem().Kind() == reflect.Pointer) {
   461  				haveAddr = false
   462  				v = e
   463  				continue
   464  			}
   465  		}
   466  
   467  		if v.Kind() != reflect.Pointer {
   468  			break
   469  		}
   470  
   471  		if decodingNull && v.CanSet() {
   472  			break
   473  		}
   474  
   475  		// Prevent infinite loop if v is an interface pointing to its own address:
   476  		//     var v any
   477  		//     v = &v
   478  		if v.Elem().Kind() == reflect.Interface && v.Elem().Elem().Equal(v) {
   479  			v = v.Elem()
   480  			break
   481  		}
   482  		if v.IsNil() {
   483  			v.Set(reflect.New(v.Type().Elem()))
   484  		}
   485  		if v.Type().NumMethod() > 0 && v.CanInterface() {
   486  			if u, ok := reflect.TypeAssert[Unmarshaler](v); ok {
   487  				return u, nil, reflect.Value{}
   488  			}
   489  			if !decodingNull {
   490  				if u, ok := reflect.TypeAssert[encoding.TextUnmarshaler](v); ok {
   491  					return nil, u, reflect.Value{}
   492  				}
   493  			}
   494  		}
   495  
   496  		if haveAddr {
   497  			v = v0 // restore original value after round-trip Value.Addr().Elem()
   498  			haveAddr = false
   499  		} else {
   500  			v = v.Elem()
   501  		}
   502  	}
   503  	return nil, nil, v
   504  }
   505  
   506  // array consumes an array from d.data[d.off-1:], decoding into v.
   507  // The first byte of the array ('[') has been read already.
   508  func (d *decodeState) array(v reflect.Value) error {
   509  	// Check for unmarshaler.
   510  	u, ut, pv := indirect(v, false)
   511  	if u != nil {
   512  		start := d.readIndex()
   513  		d.skip()
   514  		return u.UnmarshalJSON(d.data[start:d.off])
   515  	}
   516  	if ut != nil {
   517  		d.saveError(&UnmarshalTypeError{Value: "array", Type: v.Type(), Offset: int64(d.off)})
   518  		d.skip()
   519  		return nil
   520  	}
   521  	v = pv
   522  
   523  	// Check type of target.
   524  	switch v.Kind() {
   525  	case reflect.Interface:
   526  		if v.NumMethod() == 0 {
   527  			// Decoding into nil interface? Switch to non-reflect code.
   528  			ai := d.arrayInterface()
   529  			v.Set(reflect.ValueOf(ai))
   530  			return nil
   531  		}
   532  		// Otherwise it's invalid.
   533  		fallthrough
   534  	default:
   535  		d.saveError(&UnmarshalTypeError{Value: "array", Type: v.Type(), Offset: int64(d.off)})
   536  		d.skip()
   537  		return nil
   538  	case reflect.Array, reflect.Slice:
   539  		break
   540  	}
   541  
   542  	i := 0
   543  	for {
   544  		// Look ahead for ] - can only happen on first iteration.
   545  		d.scanWhile(scanSkipSpace)
   546  		if d.opcode == scanEndArray {
   547  			break
   548  		}
   549  
   550  		// Expand slice length, growing the slice if necessary.
   551  		if v.Kind() == reflect.Slice {
   552  			if i >= v.Cap() {
   553  				v.Grow(1)
   554  			}
   555  			if i >= v.Len() {
   556  				v.SetLen(i + 1)
   557  			}
   558  		}
   559  
   560  		if i < v.Len() {
   561  			// Decode into element.
   562  			if err := d.value(v.Index(i)); err != nil {
   563  				return err
   564  			}
   565  		} else {
   566  			// Ran out of fixed array: skip.
   567  			if err := d.value(reflect.Value{}); err != nil {
   568  				return err
   569  			}
   570  		}
   571  		i++
   572  
   573  		// Next token must be , or ].
   574  		if d.opcode == scanSkipSpace {
   575  			d.scanWhile(scanSkipSpace)
   576  		}
   577  		if d.opcode == scanEndArray {
   578  			break
   579  		}
   580  		if d.opcode != scanArrayValue {
   581  			panic(phasePanicMsg)
   582  		}
   583  	}
   584  
   585  	if i < v.Len() {
   586  		if v.Kind() == reflect.Array {
   587  			for ; i < v.Len(); i++ {
   588  				v.Index(i).SetZero() // zero remainder of array
   589  			}
   590  		} else {
   591  			v.SetLen(i) // truncate the slice
   592  		}
   593  	}
   594  	if i == 0 && v.Kind() == reflect.Slice {
   595  		v.Set(reflect.MakeSlice(v.Type(), 0, 0))
   596  	}
   597  	return nil
   598  }
   599  
   600  var nullLiteral = []byte("null")
   601  var textUnmarshalerType = reflect.TypeFor[encoding.TextUnmarshaler]()
   602  
   603  // object consumes an object from d.data[d.off-1:], decoding into v.
   604  // The first byte ('{') of the object has been read already.
   605  func (d *decodeState) object(v reflect.Value) error {
   606  	// Check for unmarshaler.
   607  	u, ut, pv := indirect(v, false)
   608  	if u != nil {
   609  		start := d.readIndex()
   610  		d.skip()
   611  		return u.UnmarshalJSON(d.data[start:d.off])
   612  	}
   613  	if ut != nil {
   614  		d.saveError(&UnmarshalTypeError{Value: "object", Type: v.Type(), Offset: int64(d.off)})
   615  		d.skip()
   616  		return nil
   617  	}
   618  	v = pv
   619  	t := v.Type()
   620  
   621  	// Decoding into nil interface? Switch to non-reflect code.
   622  	if v.Kind() == reflect.Interface && v.NumMethod() == 0 {
   623  		oi := d.objectInterface()
   624  		v.Set(reflect.ValueOf(oi))
   625  		return nil
   626  	}
   627  
   628  	var fields structFields
   629  
   630  	// Check type of target:
   631  	//   struct or
   632  	//   map[T1]T2 where T1 is string, an integer type,
   633  	//             or an encoding.TextUnmarshaler
   634  	switch v.Kind() {
   635  	case reflect.Map:
   636  		// Map key must either have string kind, have an integer kind,
   637  		// or be an encoding.TextUnmarshaler.
   638  		switch t.Key().Kind() {
   639  		case reflect.String,
   640  			reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
   641  			reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
   642  		default:
   643  			if !reflect.PointerTo(t.Key()).Implements(textUnmarshalerType) {
   644  				d.saveError(&UnmarshalTypeError{Value: "object", Type: t, Offset: int64(d.off)})
   645  				d.skip()
   646  				return nil
   647  			}
   648  		}
   649  		if v.IsNil() {
   650  			v.Set(reflect.MakeMap(t))
   651  		}
   652  	case reflect.Struct:
   653  		fields = cachedTypeFields(t)
   654  		// ok
   655  	default:
   656  		d.saveError(&UnmarshalTypeError{Value: "object", Type: t, Offset: int64(d.off)})
   657  		d.skip()
   658  		return nil
   659  	}
   660  
   661  	var mapElem reflect.Value
   662  	var origErrorContext errorContext
   663  	if d.errorContext != nil {
   664  		origErrorContext = *d.errorContext
   665  	}
   666  
   667  	for {
   668  		// Read opening " of string key or closing }.
   669  		d.scanWhile(scanSkipSpace)
   670  		if d.opcode == scanEndObject {
   671  			// closing } - can only happen on first iteration.
   672  			break
   673  		}
   674  		if d.opcode != scanBeginLiteral {
   675  			panic(phasePanicMsg)
   676  		}
   677  
   678  		// Read key.
   679  		start := d.readIndex()
   680  		d.rescanLiteral()
   681  		item := d.data[start:d.readIndex()]
   682  		key, ok := unquoteBytes(item)
   683  		if !ok {
   684  			panic(phasePanicMsg)
   685  		}
   686  
   687  		// Figure out field corresponding to key.
   688  		var subv reflect.Value
   689  		destring := false // whether the value is wrapped in a string to be decoded first
   690  
   691  		if v.Kind() == reflect.Map {
   692  			elemType := t.Elem()
   693  			if !mapElem.IsValid() {
   694  				mapElem = reflect.New(elemType).Elem()
   695  			} else {
   696  				mapElem.SetZero()
   697  			}
   698  			subv = mapElem
   699  		} else {
   700  			f := fields.byExactName[string(key)]
   701  			if f == nil {
   702  				f = fields.byFoldedName[string(foldName(key))]
   703  			}
   704  			if f != nil {
   705  				subv = v
   706  				destring = f.quoted
   707  				if d.errorContext == nil {
   708  					d.errorContext = new(errorContext)
   709  				}
   710  				for i, ind := range f.index {
   711  					if subv.Kind() == reflect.Pointer {
   712  						if subv.IsNil() {
   713  							// If a struct embeds a pointer to an unexported type,
   714  							// it is not possible to set a newly allocated value
   715  							// since the field is unexported.
   716  							//
   717  							// See https://golang.org/issue/21357
   718  							if !subv.CanSet() {
   719  								d.saveError(fmt.Errorf("json: cannot set embedded pointer to unexported struct: %v", subv.Type().Elem()))
   720  								// Invalidate subv to ensure d.value(subv) skips over
   721  								// the JSON value without assigning it to subv.
   722  								subv = reflect.Value{}
   723  								destring = false
   724  								break
   725  							}
   726  							subv.Set(reflect.New(subv.Type().Elem()))
   727  						}
   728  						subv = subv.Elem()
   729  					}
   730  					if i < len(f.index)-1 {
   731  						d.errorContext.FieldStack = append(
   732  							d.errorContext.FieldStack,
   733  							subv.Type().Field(ind).Name,
   734  						)
   735  					}
   736  					subv = subv.Field(ind)
   737  				}
   738  				d.errorContext.Struct = t
   739  				d.errorContext.FieldStack = append(d.errorContext.FieldStack, f.name)
   740  			} else if d.disallowUnknownFields {
   741  				d.saveError(fmt.Errorf("json: unknown field %q", key))
   742  			}
   743  		}
   744  
   745  		// Read : before value.
   746  		if d.opcode == scanSkipSpace {
   747  			d.scanWhile(scanSkipSpace)
   748  		}
   749  		if d.opcode != scanObjectKey {
   750  			panic(phasePanicMsg)
   751  		}
   752  		d.scanWhile(scanSkipSpace)
   753  
   754  		if destring {
   755  			switch qv := d.valueQuoted().(type) {
   756  			case nil:
   757  				if err := d.literalStore(nullLiteral, subv, false); err != nil {
   758  					return err
   759  				}
   760  			case string:
   761  				if err := d.literalStore([]byte(qv), subv, true); err != nil {
   762  					return err
   763  				}
   764  			default:
   765  				d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal unquoted value into %v", subv.Type()))
   766  			}
   767  		} else {
   768  			if err := d.value(subv); err != nil {
   769  				return err
   770  			}
   771  		}
   772  
   773  		// Write value back to map;
   774  		// if using struct, subv points into struct already.
   775  		if v.Kind() == reflect.Map {
   776  			kt := t.Key()
   777  			var kv reflect.Value
   778  			if reflect.PointerTo(kt).Implements(textUnmarshalerType) {
   779  				kv = reflect.New(kt)
   780  				if err := d.literalStore(item, kv, true); err != nil {
   781  					return err
   782  				}
   783  				kv = kv.Elem()
   784  			} else {
   785  				switch kt.Kind() {
   786  				case reflect.String:
   787  					kv = reflect.New(kt).Elem()
   788  					kv.SetString(string(key))
   789  				case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
   790  					s := string(key)
   791  					n, err := strconv.ParseInt(s, 10, 64)
   792  					if err != nil || kt.OverflowInt(n) {
   793  						d.saveError(&UnmarshalTypeError{Value: "number " + s, Type: kt, Offset: int64(start + 1)})
   794  						break
   795  					}
   796  					kv = reflect.New(kt).Elem()
   797  					kv.SetInt(n)
   798  				case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
   799  					s := string(key)
   800  					n, err := strconv.ParseUint(s, 10, 64)
   801  					if err != nil || kt.OverflowUint(n) {
   802  						d.saveError(&UnmarshalTypeError{Value: "number " + s, Type: kt, Offset: int64(start + 1)})
   803  						break
   804  					}
   805  					kv = reflect.New(kt).Elem()
   806  					kv.SetUint(n)
   807  				default:
   808  					panic("json: Unexpected key type") // should never occur
   809  				}
   810  			}
   811  			if kv.IsValid() {
   812  				v.SetMapIndex(kv, subv)
   813  			}
   814  		}
   815  
   816  		// Next token must be , or }.
   817  		if d.opcode == scanSkipSpace {
   818  			d.scanWhile(scanSkipSpace)
   819  		}
   820  		if d.errorContext != nil {
   821  			// Reset errorContext to its original state.
   822  			// Keep the same underlying array for FieldStack, to reuse the
   823  			// space and avoid unnecessary allocs.
   824  			d.errorContext.FieldStack = d.errorContext.FieldStack[:len(origErrorContext.FieldStack)]
   825  			d.errorContext.Struct = origErrorContext.Struct
   826  		}
   827  		if d.opcode == scanEndObject {
   828  			break
   829  		}
   830  		if d.opcode != scanObjectValue {
   831  			panic(phasePanicMsg)
   832  		}
   833  	}
   834  	return nil
   835  }
   836  
   837  // convertNumber converts the number literal s to a float64 or a Number
   838  // depending on the setting of d.useNumber.
   839  func (d *decodeState) convertNumber(s string) (any, error) {
   840  	if d.useNumber {
   841  		return Number(s), nil
   842  	}
   843  	f, err := strconv.ParseFloat(s, 64)
   844  	if err != nil {
   845  		return nil, &UnmarshalTypeError{Value: "number " + s, Type: reflect.TypeFor[float64](), Offset: int64(d.off)}
   846  	}
   847  	return f, nil
   848  }
   849  
   850  var numberType = reflect.TypeFor[Number]()
   851  
   852  // literalStore decodes a literal stored in item into v.
   853  //
   854  // fromQuoted indicates whether this literal came from unwrapping a
   855  // string from the ",string" struct tag option. this is used only to
   856  // produce more helpful error messages.
   857  func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool) error {
   858  	// Check for unmarshaler.
   859  	if len(item) == 0 {
   860  		// Empty string given.
   861  		d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type()))
   862  		return nil
   863  	}
   864  	isNull := item[0] == 'n' // null
   865  	u, ut, pv := indirect(v, isNull)
   866  	if u != nil {
   867  		return u.UnmarshalJSON(item)
   868  	}
   869  	if ut != nil {
   870  		if item[0] != '"' {
   871  			if fromQuoted {
   872  				d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type()))
   873  				return nil
   874  			}
   875  			val := "number"
   876  			switch item[0] {
   877  			case 'n':
   878  				val = "null"
   879  			case 't', 'f':
   880  				val = "bool"
   881  			}
   882  			d.saveError(&UnmarshalTypeError{Value: val, Type: v.Type(), Offset: int64(d.readIndex())})
   883  			return nil
   884  		}
   885  		s, ok := unquoteBytes(item)
   886  		if !ok {
   887  			if fromQuoted {
   888  				return fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())
   889  			}
   890  			panic(phasePanicMsg)
   891  		}
   892  		return ut.UnmarshalText(s)
   893  	}
   894  
   895  	v = pv
   896  
   897  	switch c := item[0]; c {
   898  	case 'n': // null
   899  		// The main parser checks that only true and false can reach here,
   900  		// but if this was a quoted string input, it could be anything.
   901  		if fromQuoted && string(item) != "null" {
   902  			d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type()))
   903  			break
   904  		}
   905  		switch v.Kind() {
   906  		case reflect.Interface, reflect.Pointer, reflect.Map, reflect.Slice:
   907  			v.SetZero()
   908  			// otherwise, ignore null for primitives/string
   909  		}
   910  	case 't', 'f': // true, false
   911  		value := item[0] == 't'
   912  		// The main parser checks that only true and false can reach here,
   913  		// but if this was a quoted string input, it could be anything.
   914  		if fromQuoted && string(item) != "true" && string(item) != "false" {
   915  			d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type()))
   916  			break
   917  		}
   918  		switch v.Kind() {
   919  		default:
   920  			if fromQuoted {
   921  				d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type()))
   922  			} else {
   923  				d.saveError(&UnmarshalTypeError{Value: "bool", Type: v.Type(), Offset: int64(d.readIndex())})
   924  			}
   925  		case reflect.Bool:
   926  			v.SetBool(value)
   927  		case reflect.Interface:
   928  			if v.NumMethod() == 0 {
   929  				v.Set(reflect.ValueOf(value))
   930  			} else {
   931  				d.saveError(&UnmarshalTypeError{Value: "bool", Type: v.Type(), Offset: int64(d.readIndex())})
   932  			}
   933  		}
   934  
   935  	case '"': // string
   936  		s, ok := unquoteBytes(item)
   937  		if !ok {
   938  			if fromQuoted {
   939  				return fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())
   940  			}
   941  			panic(phasePanicMsg)
   942  		}
   943  		switch v.Kind() {
   944  		default:
   945  			d.saveError(&UnmarshalTypeError{Value: "string", Type: v.Type(), Offset: int64(d.readIndex())})
   946  		case reflect.Slice:
   947  			if v.Type().Elem().Kind() != reflect.Uint8 {
   948  				d.saveError(&UnmarshalTypeError{Value: "string", Type: v.Type(), Offset: int64(d.readIndex())})
   949  				break
   950  			}
   951  			b := make([]byte, base64.StdEncoding.DecodedLen(len(s)))
   952  			n, err := base64.StdEncoding.Decode(b, s)
   953  			if err != nil {
   954  				d.saveError(err)
   955  				break
   956  			}
   957  			v.SetBytes(b[:n])
   958  		case reflect.String:
   959  			t := string(s)
   960  			if v.Type() == numberType && !isValidNumber(t) {
   961  				return fmt.Errorf("json: invalid number literal, trying to unmarshal %q into Number", item)
   962  			}
   963  			v.SetString(t)
   964  		case reflect.Interface:
   965  			if v.NumMethod() == 0 {
   966  				v.Set(reflect.ValueOf(string(s)))
   967  			} else {
   968  				d.saveError(&UnmarshalTypeError{Value: "string", Type: v.Type(), Offset: int64(d.readIndex())})
   969  			}
   970  		}
   971  
   972  	default: // number
   973  		if c != '-' && (c < '0' || c > '9') {
   974  			if fromQuoted {
   975  				return fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())
   976  			}
   977  			panic(phasePanicMsg)
   978  		}
   979  		switch v.Kind() {
   980  		default:
   981  			if v.Kind() == reflect.String && v.Type() == numberType {
   982  				// s must be a valid number, because it's
   983  				// already been tokenized.
   984  				v.SetString(string(item))
   985  				break
   986  			}
   987  			if fromQuoted {
   988  				return fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())
   989  			}
   990  			d.saveError(&UnmarshalTypeError{Value: "number", Type: v.Type(), Offset: int64(d.readIndex())})
   991  		case reflect.Interface:
   992  			n, err := d.convertNumber(string(item))
   993  			if err != nil {
   994  				d.saveError(err)
   995  				break
   996  			}
   997  			if v.NumMethod() != 0 {
   998  				d.saveError(&UnmarshalTypeError{Value: "number", Type: v.Type(), Offset: int64(d.readIndex())})
   999  				break
  1000  			}
  1001  			v.Set(reflect.ValueOf(n))
  1002  
  1003  		case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
  1004  			n, err := strconv.ParseInt(string(item), 10, 64)
  1005  			if err != nil || v.OverflowInt(n) {
  1006  				d.saveError(&UnmarshalTypeError{Value: "number " + string(item), Type: v.Type(), Offset: int64(d.readIndex())})
  1007  				break
  1008  			}
  1009  			v.SetInt(n)
  1010  
  1011  		case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
  1012  			n, err := strconv.ParseUint(string(item), 10, 64)
  1013  			if err != nil || v.OverflowUint(n) {
  1014  				d.saveError(&UnmarshalTypeError{Value: "number " + string(item), Type: v.Type(), Offset: int64(d.readIndex())})
  1015  				break
  1016  			}
  1017  			v.SetUint(n)
  1018  
  1019  		case reflect.Float32, reflect.Float64:
  1020  			n, err := strconv.ParseFloat(string(item), v.Type().Bits())
  1021  			if err != nil || v.OverflowFloat(n) {
  1022  				d.saveError(&UnmarshalTypeError{Value: "number " + string(item), Type: v.Type(), Offset: int64(d.readIndex())})
  1023  				break
  1024  			}
  1025  			v.SetFloat(n)
  1026  		}
  1027  	}
  1028  	return nil
  1029  }
  1030  
  1031  // The xxxInterface routines build up a value to be stored
  1032  // in an empty interface. They are not strictly necessary,
  1033  // but they avoid the weight of reflection in this common case.
  1034  
  1035  // valueInterface is like value but returns any.
  1036  func (d *decodeState) valueInterface() (val any) {
  1037  	switch d.opcode {
  1038  	default:
  1039  		panic(phasePanicMsg)
  1040  	case scanBeginArray:
  1041  		val = d.arrayInterface()
  1042  		d.scanNext()
  1043  	case scanBeginObject:
  1044  		val = d.objectInterface()
  1045  		d.scanNext()
  1046  	case scanBeginLiteral:
  1047  		val = d.literalInterface()
  1048  	}
  1049  	return
  1050  }
  1051  
  1052  // arrayInterface is like array but returns []any.
  1053  func (d *decodeState) arrayInterface() []any {
  1054  	var v = make([]any, 0)
  1055  	for {
  1056  		// Look ahead for ] - can only happen on first iteration.
  1057  		d.scanWhile(scanSkipSpace)
  1058  		if d.opcode == scanEndArray {
  1059  			break
  1060  		}
  1061  
  1062  		v = append(v, d.valueInterface())
  1063  
  1064  		// Next token must be , or ].
  1065  		if d.opcode == scanSkipSpace {
  1066  			d.scanWhile(scanSkipSpace)
  1067  		}
  1068  		if d.opcode == scanEndArray {
  1069  			break
  1070  		}
  1071  		if d.opcode != scanArrayValue {
  1072  			panic(phasePanicMsg)
  1073  		}
  1074  	}
  1075  	return v
  1076  }
  1077  
  1078  // objectInterface is like object but returns map[string]any.
  1079  func (d *decodeState) objectInterface() map[string]any {
  1080  	m := make(map[string]any)
  1081  	for {
  1082  		// Read opening " of string key or closing }.
  1083  		d.scanWhile(scanSkipSpace)
  1084  		if d.opcode == scanEndObject {
  1085  			// closing } - can only happen on first iteration.
  1086  			break
  1087  		}
  1088  		if d.opcode != scanBeginLiteral {
  1089  			panic(phasePanicMsg)
  1090  		}
  1091  
  1092  		// Read string key.
  1093  		start := d.readIndex()
  1094  		d.rescanLiteral()
  1095  		item := d.data[start:d.readIndex()]
  1096  		key, ok := unquote(item)
  1097  		if !ok {
  1098  			panic(phasePanicMsg)
  1099  		}
  1100  
  1101  		// Read : before value.
  1102  		if d.opcode == scanSkipSpace {
  1103  			d.scanWhile(scanSkipSpace)
  1104  		}
  1105  		if d.opcode != scanObjectKey {
  1106  			panic(phasePanicMsg)
  1107  		}
  1108  		d.scanWhile(scanSkipSpace)
  1109  
  1110  		// Read value.
  1111  		m[key] = d.valueInterface()
  1112  
  1113  		// Next token must be , or }.
  1114  		if d.opcode == scanSkipSpace {
  1115  			d.scanWhile(scanSkipSpace)
  1116  		}
  1117  		if d.opcode == scanEndObject {
  1118  			break
  1119  		}
  1120  		if d.opcode != scanObjectValue {
  1121  			panic(phasePanicMsg)
  1122  		}
  1123  	}
  1124  	return m
  1125  }
  1126  
  1127  // literalInterface consumes and returns a literal from d.data[d.off-1:] and
  1128  // it reads the following byte ahead. The first byte of the literal has been
  1129  // read already (that's how the caller knows it's a literal).
  1130  func (d *decodeState) literalInterface() any {
  1131  	// All bytes inside literal return scanContinue op code.
  1132  	start := d.readIndex()
  1133  	d.rescanLiteral()
  1134  
  1135  	item := d.data[start:d.readIndex()]
  1136  
  1137  	switch c := item[0]; c {
  1138  	case 'n': // null
  1139  		return nil
  1140  
  1141  	case 't', 'f': // true, false
  1142  		return c == 't'
  1143  
  1144  	case '"': // string
  1145  		s, ok := unquote(item)
  1146  		if !ok {
  1147  			panic(phasePanicMsg)
  1148  		}
  1149  		return s
  1150  
  1151  	default: // number
  1152  		if c != '-' && (c < '0' || c > '9') {
  1153  			panic(phasePanicMsg)
  1154  		}
  1155  		n, err := d.convertNumber(string(item))
  1156  		if err != nil {
  1157  			d.saveError(err)
  1158  		}
  1159  		return n
  1160  	}
  1161  }
  1162  
  1163  // getu4 decodes \uXXXX from the beginning of s, returning the hex value,
  1164  // or it returns -1.
  1165  func getu4(s []byte) rune {
  1166  	if len(s) < 6 || s[0] != '\\' || s[1] != 'u' {
  1167  		return -1
  1168  	}
  1169  	var r rune
  1170  	for _, c := range s[2:6] {
  1171  		switch {
  1172  		case '0' <= c && c <= '9':
  1173  			c = c - '0'
  1174  		case 'a' <= c && c <= 'f':
  1175  			c = c - 'a' + 10
  1176  		case 'A' <= c && c <= 'F':
  1177  			c = c - 'A' + 10
  1178  		default:
  1179  			return -1
  1180  		}
  1181  		r = r*16 + rune(c)
  1182  	}
  1183  	return r
  1184  }
  1185  
  1186  // unquote converts a quoted JSON string literal s into an actual string t.
  1187  // The rules are different than for Go, so cannot use strconv.Unquote.
  1188  func unquote(s []byte) (t string, ok bool) {
  1189  	s, ok = unquoteBytes(s)
  1190  	t = string(s)
  1191  	return
  1192  }
  1193  
  1194  func unquoteBytes(s []byte) (t []byte, ok bool) {
  1195  	if len(s) < 2 || s[0] != '"' || s[len(s)-1] != '"' {
  1196  		return
  1197  	}
  1198  	s = s[1 : len(s)-1]
  1199  
  1200  	// Check for unusual characters. If there are none,
  1201  	// then no unquoting is needed, so return a slice of the
  1202  	// original bytes.
  1203  	r := 0
  1204  	for r < len(s) {
  1205  		c := s[r]
  1206  		if c == '\\' || c == '"' || c < ' ' {
  1207  			break
  1208  		}
  1209  		rr, size := utf8.DecodeRune(s[r:])
  1210  		if rr == utf8.RuneError && size == 1 {
  1211  			break
  1212  		}
  1213  		r += size
  1214  	}
  1215  	if r == len(s) {
  1216  		return s, true
  1217  	}
  1218  
  1219  	b := make([]byte, len(s)+2*utf8.UTFMax)
  1220  	w := copy(b, s[0:r])
  1221  	for r < len(s) {
  1222  		// Out of room? Can only happen if s is full of
  1223  		// malformed UTF-8 and we're replacing each
  1224  		// byte with RuneError.
  1225  		if w >= len(b)-2*utf8.UTFMax {
  1226  			nb := make([]byte, (len(b)+utf8.UTFMax)*2)
  1227  			copy(nb, b[0:w])
  1228  			b = nb
  1229  		}
  1230  		switch c := s[r]; {
  1231  		case c == '\\':
  1232  			r++
  1233  			if r >= len(s) {
  1234  				return
  1235  			}
  1236  			switch s[r] {
  1237  			default:
  1238  				return
  1239  			case '"', '\\', '/', '\'':
  1240  				b[w] = s[r]
  1241  				r++
  1242  				w++
  1243  			case 'b':
  1244  				b[w] = '\b'
  1245  				r++
  1246  				w++
  1247  			case 'f':
  1248  				b[w] = '\f'
  1249  				r++
  1250  				w++
  1251  			case 'n':
  1252  				b[w] = '\n'
  1253  				r++
  1254  				w++
  1255  			case 'r':
  1256  				b[w] = '\r'
  1257  				r++
  1258  				w++
  1259  			case 't':
  1260  				b[w] = '\t'
  1261  				r++
  1262  				w++
  1263  			case 'u':
  1264  				r--
  1265  				rr := getu4(s[r:])
  1266  				if rr < 0 {
  1267  					return
  1268  				}
  1269  				r += 6
  1270  				if utf16.IsSurrogate(rr) {
  1271  					rr1 := getu4(s[r:])
  1272  					if dec := utf16.DecodeRune(rr, rr1); dec != unicode.ReplacementChar {
  1273  						// A valid pair; consume.
  1274  						r += 6
  1275  						w += utf8.EncodeRune(b[w:], dec)
  1276  						break
  1277  					}
  1278  					// Invalid surrogate; fall back to replacement rune.
  1279  					rr = unicode.ReplacementChar
  1280  				}
  1281  				w += utf8.EncodeRune(b[w:], rr)
  1282  			}
  1283  
  1284  		// Quote, control characters are invalid.
  1285  		case c == '"', c < ' ':
  1286  			return
  1287  
  1288  		// ASCII
  1289  		case c < utf8.RuneSelf:
  1290  			b[w] = c
  1291  			r++
  1292  			w++
  1293  
  1294  		// Coerce to well-formed UTF-8.
  1295  		default:
  1296  			rr, size := utf8.DecodeRune(s[r:])
  1297  			r += size
  1298  			w += utf8.EncodeRune(b[w:], rr)
  1299  		}
  1300  	}
  1301  	return b[0:w], true
  1302  }
  1303  

View as plain text