diff --git a/Makefile b/Makefile index 3163dad..6419212 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .DEFAULT_GOAL := all .PHONY: all -all: test lint +all: test lint fuzz # the TEST_FLAGS env var can be set to eg run only specific tests .PHONY: test @@ -12,6 +12,10 @@ test: bench: go test -bench=. +.PHONY: fuzz +fuzz: + go test -fuzz=. -fuzztime=10s ./... + .PHONY: lint lint: golangci-lint run diff --git a/json.go b/json.go index f113e3f..b85c4a7 100644 --- a/json.go +++ b/json.go @@ -18,6 +18,10 @@ var ( // MarshalJSON implements the json.Marshaler interface. func (om *OrderedMap[K, V]) MarshalJSON() ([]byte, error) { //nolint:funlen + if om == nil || om.list == nil { + return []byte("null"), nil + } + writer := jwriter.Writer{} writer.RawByte('{')