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"

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);