decoder_amd64.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // +build amd64,go1.16,!go1.22
  2. /*
  3. * Copyright 2023 ByteDance Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package decoder
  18. import (
  19. `github.com/bytedance/sonic/internal/decoder`
  20. )
  21. // Decoder is the decoder context object
  22. type Decoder = decoder.Decoder
  23. // SyntaxError represents json syntax error
  24. type SyntaxError = decoder.SyntaxError
  25. // MismatchTypeError represents dismatching between json and object
  26. type MismatchTypeError = decoder.MismatchTypeError
  27. // Options for decode.
  28. type Options = decoder.Options
  29. const (
  30. OptionUseInt64 Options = decoder.OptionUseInt64
  31. OptionUseNumber Options = decoder.OptionUseNumber
  32. OptionUseUnicodeErrors Options = decoder.OptionUseUnicodeErrors
  33. OptionDisableUnknown Options = decoder.OptionDisableUnknown
  34. OptionCopyString Options = decoder.OptionCopyString
  35. OptionValidateString Options = decoder.OptionValidateString
  36. )
  37. // StreamDecoder is the decoder context object for streaming input.
  38. type StreamDecoder = decoder.StreamDecoder
  39. var (
  40. // NewDecoder creates a new decoder instance.
  41. NewDecoder = decoder.NewDecoder
  42. // NewStreamDecoder adapts to encoding/json.NewDecoder API.
  43. //
  44. // NewStreamDecoder returns a new decoder that reads from r.
  45. NewStreamDecoder = decoder.NewStreamDecoder
  46. // Pretouch compiles vt ahead-of-time to avoid JIT compilation on-the-fly, in
  47. // order to reduce the first-hit latency.
  48. //
  49. // Opts are the compile options, for example, "option.WithCompileRecursiveDepth" is
  50. // a compile option to set the depth of recursive compile for the nested struct type.
  51. Pretouch = decoder.Pretouch
  52. // Skip skips only one json value, and returns first non-blank character position and its ending position if it is valid.
  53. // Otherwise, returns negative error code using start and invalid character position using end
  54. Skip = decoder.Skip
  55. )