We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When empty map is present in Structure sheriff.Marshal() gives nil but json.Marshal() gives empty json {}
nil
{}
I used existing test TestMarshal_EmptyMap and Marshal same object using json & sheriff and got different results.
TestMarshal_EmptyMap
Modified Test func:
func TestMarshal_EmptyMap(t *testing.T) { emp := EmptyMapTest{ AMap: make(map[string]string), } o := &Options{ Groups: []string{"test"}, } actualMap, err := Marshal(o, emp) assert.NoError(t, err) actual, err := json.Marshal(actualMap) assert.NoError(t, err) expected, err := json.Marshal(emp) assert.NoError(t, err) assert.Equal(t, string(expected), string(actual)) }
Test result:
--- FAIL: TestMarshal_EmptyMap (0.00s) sheriff_test.go:510: Error Trace: sheriff_test.go:510 Error: Not equal: expected: "{\"a_map\":{}}" actual : "{\"a_map\":null}" Diff: --- Expected +++ Actual @@ -1 +1 @@ -{"a_map":{}} +{"a_map":null} Test: TestMarshal_EmptyMap FAIL
The text was updated successfully, but these errors were encountered:
oh yeah, that looks like a bug. Wondering if that breaks existing users if we change it.. but would you be open to create a PR for it?
Sorry, something went wrong.
@mweibel created a PR. Can you review & let me know how can I trigger lint & test?
Successfully merging a pull request may close this issue.
When empty map is present in Structure sheriff.Marshal() gives
nil
but json.Marshal() gives empty json{}
I used existing test
TestMarshal_EmptyMap
and Marshal same object using json & sheriff and got different results.Modified Test func:
Test result:
The text was updated successfully, but these errors were encountered: