Explores the challenge of distinguishing zero from null values in JSON while using Go. It presents three techniques to address this issue: pointer semantics, using maps, and applying default values, each with its advantages and drawbacks. The article provides code examples to illustrate each method and emphasizes the importance of appropriate JSON field validation.

8m read timeFrom ardanlabs.com
Post cover image
Table of contents
IntroductionSimple UnmarshallingZero Values vs NULLUsing Pointer SemanticsUsing A MapUsing Default ValuesConclusion

Sort: