I am creating an API that returns results as JSON. Is there a best practice for whether to include keys in the result when the value is null? For example:
{ "title":"Foo Bar", "author":"Joe Blow", "isbn":null }
or
{ "title":"Foo Bar", "author":"Joe Blow" }
Since the second one is less, I am inclined to this style, but I'm not sure if there is a preferred style or not. From the client’s point of view, it seems that both styles will be functionally equivalent. Any pros or cons for everyone?
json javascript null undefined
jjathman Jun 12 '12 at 19:23 2012-06-12 19:23
source share