mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 22:35:27 +00:00
* perf(*): replace `encoding/json` w/ sonic Signed-off-by: Dwi Siswanto <git@dw1.io> * feat(utils): add `json` pkg (sonic wrapper) Signed-off-by: Dwi Siswanto <git@dw1.io> * chore(*): use `sonic` wrapper instead Signed-off-by: Dwi Siswanto <git@dw1.io> * chore(*): replace `sonic.ConfigStd` -> `json` (wrapper) Signed-off-by: Dwi Siswanto <git@dw1.io> * test(model): adjust expected marshal'd JSON Signed-off-by: Dwi Siswanto <git@dw1.io> * feat(json): dynamic backend; `sonic` -> `go-json` (fallback) Signed-off-by: Dwi Siswanto <git@dw1.io> * chore(json): merge config - as its not usable Signed-off-by: Dwi Siswanto <git@dw1.io> * chore(json): rm go version constraints Signed-off-by: Dwi Siswanto <git@dw1.io> * chore: go mod tidy Signed-off-by: Dwi Siswanto <git@dw1.io> --------- Signed-off-by: Dwi Siswanto <git@dw1.io>
32 lines
945 B
Go
32 lines
945 B
Go
package json
|
|
|
|
import "errors"
|
|
|
|
// Message is a raw encoded JSON value.
|
|
// It implements [Marshaler] and [Unmarshaler] and can
|
|
// be used to delay JSON decoding or precompute a JSON encoding.
|
|
//
|
|
// Copied from: https://cs.opensource.google/go/go/+/refs/tags/go1.23.6:src/encoding/json/stream.go;l=256-276
|
|
type Message []byte
|
|
|
|
// MarshalJSON returns m as the JSON encoding of m.
|
|
//
|
|
// Copied from: https://cs.opensource.google/go/go/+/refs/tags/go1.23.6:src/encoding/json/stream.go;l=256-276
|
|
func (m Message) MarshalJSON() ([]byte, error) {
|
|
if m == nil {
|
|
return []byte("null"), nil
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
// UnmarshalJSON sets *m to a copy of data.
|
|
//
|
|
// Copied from: https://cs.opensource.google/go/go/+/refs/tags/go1.23.6:src/encoding/json/stream.go;l=256-276
|
|
func (m *Message) UnmarshalJSON(data []byte) error {
|
|
if m == nil {
|
|
return errors.New("json.Message: UnmarshalJSON on nil pointer")
|
|
}
|
|
*m = append((*m)[0:0], data...)
|
|
return nil
|
|
}
|