
PATCH vs. "Drop Null Properties": Two Google-Style Ways to Clear a Field
If your API drops null properties from its JSON, PATCH can no longer tell "clear this field" apart from "leave it alone." In this post, I'll show two ways I've solved that while still following Google's API guidelines. When designing APIs, I often refer to Google's AIPs (API Improvement Proposals) and Style Guides. The Google JSON Style Guide has a rule that says to "consider removing properties with null values." In other words, for a Users resource with name and age, if age is unset (NULL), the recommended JSON looks like this: Adopting this rule, however, creates a problem when implementing PATCH (partial updates). Yes, the "drop nulls" rule and PATCH can coexist (or so I believe).

