You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-24 23:16:47 +02:00
adapter api comment
This commit is contained in:
@ -5,7 +5,9 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Unmarshal adapts to json/encoding APIs
|
// Unmarshal adapts to json/encoding Unmarshal API
|
||||||
|
//
|
||||||
|
// Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v.
|
||||||
func Unmarshal(data []byte, v interface{}) error {
|
func Unmarshal(data []byte, v interface{}) error {
|
||||||
data = data[:lastNotSpacePos(data)]
|
data = data[:lastNotSpacePos(data)]
|
||||||
iter := ParseBytes(data)
|
iter := ParseBytes(data)
|
||||||
@ -81,7 +83,7 @@ func UnmarshalAnyFromString(str string) (Any, error) {
|
|||||||
return nil, iter.Error
|
return nil, iter.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marshal is an adapter to json.Marshal
|
// Marshal adapts to json/encoding Marshal API
|
||||||
//
|
//
|
||||||
// Marshal returns the JSON encoding of v, adapts to json/encoding Marshal API
|
// Marshal returns the JSON encoding of v, adapts to json/encoding Marshal API
|
||||||
func Marshal(v interface{}) ([]byte, error) {
|
func Marshal(v interface{}) ([]byte, error) {
|
||||||
@ -95,7 +97,6 @@ func Marshal(v interface{}) ([]byte, error) {
|
|||||||
return buf.Bytes(), nil
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// notbeginwithfuncname MarshalToString does not show in doc
|
|
||||||
func MarshalToString(v interface{}) (string, error) {
|
func MarshalToString(v interface{}) (string, error) {
|
||||||
buf, err := Marshal(v)
|
buf, err := Marshal(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -104,7 +105,9 @@ func MarshalToString(v interface{}) (string, error) {
|
|||||||
return string(buf), nil
|
return string(buf), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDecoder show in doc
|
// NewDecoder adapts to json/stream NewDecoder API.
|
||||||
|
//
|
||||||
|
// NewDecoder returns a new decoder that reads from r.
|
||||||
func NewDecoder(reader io.Reader) *AdaptedDecoder {
|
func NewDecoder(reader io.Reader) *AdaptedDecoder {
|
||||||
iter := Parse(reader, 512)
|
iter := Parse(reader, 512)
|
||||||
return &AdaptedDecoder{iter}
|
return &AdaptedDecoder{iter}
|
||||||
|
Reference in New Issue
Block a user