Hapus ruang dan garis dari JSON di PHP

$before = '{ "key": "value with whitespaces to maintain" }';
$after  = json_encode(json_decode($before));
Ankur