首页 > 解决方案 > 为什么json解码后不打印空值?

问题描述

当 json 解码工作时,它会从数组中删除 Null 或 0 值,为什么?

下面的例子。

Array ( [address] => Array ( [address] => [postalCode] => [phoneNumber] => testing [city] => ) )

我得到了这个为什么它没有在空值或 0 中显示 null。

$test = '{"address": {
            "address": null,
            "postalCode": null,
            "phoneNumber": "testing",
            "city": null
        }}';


  $test_decoded =json_decode($test, true);
 print_r($test_decoded);

它应该返回 null 值或 0 值

标签: phpjsondecode

解决方案


推荐阅读