Answers:
如果属性是可选的或具有空值或null值,请考虑从JSON删除该属性,除非存在强烈的语义上的原因。
{
"volume": 10,
// Even though the "balance" property's value is zero, it should be left in,
// since "0" signifies "even balance" (the value could be "-1" for left
// balance and "+1" for right balance.
"balance": 0,
// The "currentlyPlaying" property can be left out since it is null.
// "currentlyPlaying": null
}
currentlyPlaying
在某些响应中,而不是其他响应中,还是希望客户端检查密钥是否存在而不是检查密钥是否为null?