sheriff icon indicating copy to clipboard operation
sheriff copied to clipboard

Fix embedded struct marshalling

Open alecsammon opened this issue 1 year ago • 1 comments

Fixes struct marshalling for embedded structs when a json tag is specified.

Currently the following case works, and produces the same result as json.Marshal

type EmbeddedParent struct {
	*EmbeddedChild
}

However this case does not work as expected

type EmbeddedParent struct {
	*EmbeddedChild `json:"embedded"`
}

In the second case the outputted json is flattened, instead of nested as expected.

alecsammon avatar Jul 03 '24 14:07 alecsammon

Coverage Status

coverage: 89.212% (+0.05%) from 89.167% when pulling 5579d0b614a5271922b64bab347ba956345a8bce on alecsammon:fix_embedded into e127e90d6237c4c4928b986f66ab89815400a9a9 on liip:master.

coveralls avatar Jul 03 '24 14:07 coveralls

Coverage Status

coverage: 89.212% (+0.05%) from 89.167% when pulling 80f0f5c7f04dc87a6f12d439f8386e3726562642 on alecsammon:fix_embedded into dc3eac4ae2046ea77888370afa3b3ff5b3fbe9f7 on liip:master.

coveralls avatar Oct 03 '24 06:10 coveralls

❤️ - thank you

alecsammon avatar Oct 03 '24 06:10 alecsammon

sorry, got off my radar and just came across this because of another PR coming in :)

mweibel avatar Oct 03 '24 06:10 mweibel

no problem at all - we've been using our own fork for the moment - but can now switch back to use this.

alecsammon avatar Oct 03 '24 07:10 alecsammon