Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我一直在研究检测空 JSON 对象的问题,但无法获得我在此处找到的一些建议。
似乎有效的解决方案是:
if ( Ti.JSON.stringify ( json ) != "{}" )
有人看到这种方法有什么问题吗?
对于空字符串或空值,这可能会出现问题。
json = ''; Ti.API.log(JSON.stringify(json)); // would output "" json = null; Ti.API.log(JSON.stringify(json)); // would output "null"