dousi2553 2012-03-07 08:05 采纳率: 0%
浏览 53
已采纳

Null从JSON_Encode返回

print(json_encode($output));

Hello, the above statement in PHP might have the probability of printing null to my Android application.

How do I check whether the json is a null on my Android application?

Update: Since json_encode() method returns a "null" , you can check whether the response you get from executing the httppost/httpget whether it is a "null" before assigning it to a JSONArray. Note that PHP's actual null value when you load a page is empty while printing a null JSON_Encode is actually a "null" String. Therefore you would need to check ".equals("null") on your Android side rather than "== null"

  • 写回答

1条回答 默认 最新

  • douwo3665 2012-03-07 08:12
    关注

    Map null to the empty structure {} or empty array [] to avoid the issue?

    You might also need to use force object...

    json_encode($foo, JSON_FORCE_OBJECT);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog