2

I'm developing a web api for common CRUD operations (entities like Products, Categories) and I want to know pro/cons to suppress null properties and what should I take care choosing to ignore or not ignore these fields.

Example:

{
    "name": "Product A",
    "description": null
}

or

{
    "name": "Product A"
}
m.rufca
  • 2,558
  • 2
  • 19
  • 26
  • After ask I found two links but it wasnt conclusive to me. http://stackoverflow.com/questions/15686995 http://programmers.stackexchange.com/questions/285010 – m.rufca Jun 17 '16 at 00:01

2 Answers2

2

If the client send an explict null he wants to delete the value for this property. In your first example he wants to delete the description value.

If the client does not send a property at all, he wants to leave the value of the property unchanged. In your second example he wants to leave the value of description and all other properties except name unchanged.

0

While you are creating new record no issues with both.But while you updating a new record if you pass null for description the record already in the db for description will be deleted, if you don't pass anything the record already in db will exist as it is.