Returning an empty list on Google App Engine behaves differently on the dev server and when deployed

烂漫一生 提交于 2019-12-06 13:30:44

The expected behavior is that empty lists will be omitted, as per the documentation [1]:

Empty Lists that are returned will arrive as nulls on the client-side. Remember to check for those.

So the actual issue is the development server is not consistent with production. As a workaround for consistency on the development server, you can add a check for an empty list and return null instead.

return list.isEmpty() ? null : list;

[1] https://cloud.google.com/solutions/mobile/google-cloud-endpoints-for-android/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!