// Copyright (C) 2022-2023 Luke Shumaker // // SPDX-License-Identifier: GPL-2.0-or-later package lowmemjson import ( "encoding" "encoding/json" "reflect" ) // A Number represents a JSON number value. It is represented as a // string containing the raw JSON text; it is useful for preserving // number values with perfect fidelity, but isn't so useful for use as // a number value in a Go program. type Number = json.Number // A RawMessage is a raw encoded JSON value. This saves time when // encoding or decoding, but does mean that the full text must be // buffered when decoding. type RawMessage = json.RawMessage type ( jsonMarshaler = json.Marshaler jsonUnmarshaler = json.Unmarshaler ) var ( // common types. numberType = reflect.TypeOf(Number("")) byteType = reflect.TypeOf(byte(0)) byteSliceType = reflect.TypeOf(([]byte)(nil)) // encodable/marshaler types. encodableType = reflect.TypeOf((*Encodable)(nil)).Elem() jsonMarshalerType = reflect.TypeOf((*json.Marshaler)(nil)).Elem() textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem() // decodable/unmarshaler types. decodableType = reflect.TypeOf((*Decodable)(nil)).Elem() jsonUnmarshalerType = reflect.TypeOf((*json.Unmarshaler)(nil)).Elem() textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem() // other types used by Decoder. rawMessagePtrType = reflect.TypeOf((*json.RawMessage)(nil)) float64Type = reflect.TypeOf(float64(0)) )