Conversation
hanzei
approved these changes
Sep 28, 2026
| {"populated interface map", map[interface{}]interface{}{1: "value"}, `{"1":"value"}`}, | ||
| } | ||
| for _, test := range tests { | ||
| t.Run(test.name, func(t *testing.T) { |
Collaborator
There was a problem hiding this comment.
Can we t.Parralell() these tests?
Author
There was a problem hiding this comment.
Added t.Parallel() to the table cases and captured the loop variable for Go 1.20/1.21. The full suite and five shuffled race-detector runs pass on Windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
JSON conversion currently changes some nil slices and maps into empty arrays and objects. For example,
objx.Map{"items": []interface{}(nil)}becomes{"items":[]}instead of{"items":null}. This loses the distinction between a null collection and an empty one; nil plain string-keyed maps and nil string slices already retain it.Return nil from the existing cleanup helpers before allocating their output. Nil containers now remain null, while non-nil empty containers still become
[]or{}. No new map types or recursive conversion paths are added.The regression table covers nil, empty and populated containers directly and inside another map or slice. It checks JSON, MustJSON and the decoded Base64 output. All 54 cases pass; 15 fail before this change. The table cases run in parallel, with a per-iteration copy for older Go versions. The full suite and vet pass on Windows with Go 1.23.0 and 1.27.1. Five shuffled full-suite runs with the race detector also pass on Go 1.27.1.
Checklist
go test -race ./...command used bytask testpasses locally with CGO enabled. Local validation covers Windows; the updated Ubuntu CI matrix is pending.gofmt -d -son the committed LF content of all Go files produces no changes, andgo vet ./...passes.