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 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件