In server side with PHP,
You can use array_filter
before json_encode
.
array_filter
without second argument removes null elements of entry array, example :
$object= array(
0 => 'foo',
1 => false,
2 => -1,
3 => null,
4 => ''
);
$object = (object) array_filter((array) $object);
$result = json_encode($object);
The $result
contains:
{"0":"foo","2":-1}
As you see, the null elements are removed.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…