Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/utils/json/jsoncodec.go
2070 views
1
package json
2
3
// Marshaler is the interface implemented by types that
4
// can marshal themselves into valid JSON.
5
type Marshaler interface {
6
MarshalJSON() ([]byte, error)
7
}
8
9
// Unmarshaler is the interface implemented by types
10
// that can unmarshal a JSON description of themselves.
11
// The input can be assumed to be a valid encoding of
12
// a JSON value. UnmarshalJSON must copy the JSON data
13
// if it wishes to retain the data after returning.
14
//
15
// By convention, to approximate the behavior of [Unmarshal] itself,
16
// Unmarshalers implement UnmarshalJSON([]byte("null")) as a no-op.
17
type Unmarshaler interface {
18
UnmarshalJSON([]byte) error
19
}
20
21
// JSONCodec is the interface implemented by types that can marshal and
22
// unmarshal themselves into valid JSON.
23
type JSONCodec interface {
24
Marshaler
25
Unmarshaler
26
}
27
28