When there is no value assigned to a property, should it be returned as null or REST API should entirely skip such properties?
Consider an example of user object which has first_name and last_name. (In the below example, last_name need not be an empty string specifically. Consider it was never received from the end user.)
{
first_name: "Bob",
last_name: "",
}
Now since the client is aware of User schema, should last_name be returned or simply dropped from response so that client can automatically set a default value.(i.e empty string ""
)
In case null has to be returned, does it make sense to return null when it has got a special meaning in some cases.(i.e null
means something and different from undefined
)
from What should be returned when a property does not have a value in a REST api?
No comments:
Post a Comment