【问题标题】:checking for empty json in Titanium在 Titanium 中检查空 json
【发布时间】:2012-04-25 21:04:59
【问题描述】:

我一直在研究检测空 JSON 对象的问题,但无法获得我在此处找到的一些工作建议。

似乎可行的解决方案是:

if ( Ti.JSON.stringify ( json ) != "{}" )

有人发现这种方法有什么问题吗?

【问题讨论】:

    标签: javascript json titanium


    【解决方案1】:

    这对于空字符串或空值可能会产生问题。

    json = '';
    Ti.API.log(JSON.stringify(json));  // would output ""
    
    json = null;
    Ti.API.log(JSON.stringify(json));  // would output "null"
    

    【讨论】:

      猜你喜欢
      • 2015-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多