nuclei/pkg/utils/json/jsoncodec.go

27 lines
811 B
Go
Raw Normal View History

package json
// Marshaler is the interface implemented by types that
// can marshal themselves into valid JSON.
type Marshaler interface {
MarshalJSON() ([]byte, error)
}
// Unmarshaler is the interface implemented by types
// that can unmarshal a JSON description of themselves.
// The input can be assumed to be a valid encoding of
// a JSON value. UnmarshalJSON must copy the JSON data
// if it wishes to retain the data after returning.
//
// By convention, to approximate the behavior of [Unmarshal] itself,
// Unmarshalers implement UnmarshalJSON([]byte("null")) as a no-op.
type Unmarshaler interface {
UnmarshalJSON([]byte) error
}
// JSONCodec is the interface implemented by types that can marshal and
// unmarshal themselves into valid JSON.
type JSONCodec interface {
Marshaler
Unmarshaler
}