json

package
v0.0.0-...-27647ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2023 License: BSD-3-Clause Imports: 14 Imported by: 1

Documentation

Overview

Copyright (c) 2009 The Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Copyright (c) 2009 The Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Copyright (c) 2009 The Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendEncodedString

func AppendEncodedString(buf []byte, s string, escapeHTML bool) []byte

FIXME: :|

func BackslashBytes

func BackslashBytes() []byte

func BoolBytes

func BoolBytes(v bool) []byte

func CanMarshalAsText

func CanMarshalAsText(ty reflect.Type) bool

func CanUnmarshalAsText

func CanUnmarshalAsText(ty reflect.Type) bool

func EmptyObjectBytes

func EmptyObjectBytes() []byte

func EncodeFloat32

func EncodeFloat32(w io.Writer, f float32) error

func EncodeFloat64

func EncodeFloat64(w io.Writer, f float64) error

func EncodeString

func EncodeString(w io.Writer, s string, escapeHTML bool) error

func EncodeStringBytes

func EncodeStringBytes(w io.Writer, s []byte, escapeHTML bool) error

NOTE: keep in sync with string above.

func EndDelim

func EndDelim(d json.Delim) json.Delim

func FalseBytes

func FalseBytes() []byte

func IsBackslashBytes

func IsBackslashBytes(b []byte) bool

func IsFalseBytes

func IsFalseBytes(b []byte) bool

func IsHtmlSafeRune

func IsHtmlSafeRune(r rune) bool

func IsNullBytes

func IsNullBytes(b []byte) bool

func IsPrimitiveTextType

func IsPrimitiveTextType(ty reflect.Type) bool

func IsQuoteBytes

func IsQuoteBytes(b []byte) bool

func IsSafeRune

func IsSafeRune(r rune) bool

func IsTrueBytes

func IsTrueBytes(b []byte) bool

func IsValidNumber

func IsValidNumber(s string) bool

isValidNumber reports whether s is a valid JSON number literal.

func MarshalAsText

func MarshalAsText(v reflect.Value) (string, error)

func MarshalIndentString

func MarshalIndentString(v any, prefix, indent string) (string, error)

func MarshalPretty

func MarshalPretty(v any) (string, error)

func MarshalString

func MarshalString(v any) (string, error)

func NullBytes

func NullBytes() []byte

func QuoteBytes

func QuoteBytes() []byte

func RawFieldOf

func RawFieldOf(k string, v json.RawMessage) bt.Kv[string, json.RawMessage]

func ReadDelim

func ReadDelim(dec *json.Decoder) (json.Delim, error)

func TrueBytes

func TrueBytes() []byte

func UnmarshalAs

func UnmarshalAs[T any](b []byte) (v T, err error)

func UnmarshalAsText

func UnmarshalAsText(s string, v reflect.Value) error

func UnmarshalObjectFields

func UnmarshalObjectFields[K, V any](b []byte) ([]bt.Kv[K, V], error)

func UnmarshalRawObjectFields

func UnmarshalRawObjectFields[K, V any](o RawObject) ([]bt.Kv[K, V], error)

func Unquote

func Unquote(s []byte) (t string, ok bool)

unquote converts a quoted JSON string literal s into an actual string t. The rules are different than for Go, so cannot use strconv.Unquote.

func UnquoteBytes

func UnquoteBytes(s []byte) (t []byte, ok bool)

Types

type RawField

type RawField = bt.Kv[string, json.RawMessage]

type RawObject

type RawObject []RawField

func DecodeRawObject

func DecodeRawObject(dec *json.Decoder) (r RawObject, err error)

func MakeRawObject

func MakeRawObject[K, V any](kvs []bt.Kv[K, V]) (RawObject, error)

func (RawObject) MarshalJSON

func (o RawObject) MarshalJSON() ([]byte, error)

func (*RawObject) UnmarshalJSON

func (o *RawObject) UnmarshalJSON(b []byte) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL