I am compressing the array as below,
<?php
$input = array('name'=>'PHP');
$compressed = gzcompress(serialize($input));
echo '<pre>'; print_r($compressed);
?>
And it is printing the data as below
xœK´2´ª.¶2±RÊKÌMU².¶2¶R
ðP²®nJ»
Now, I would like to convert $compressed
as a json string. Since the compressed data contains special characters, it throws error, So I tried JSON_UNESCAPED_UNICODE
below is the code snippet.
<?php
// $compressed value getting from above script
echo json_encode($compressed,JSON_UNESCAPED_UNICODE);
?>
Still it is not working. Can anyone suggest how to encode a compressed data as a json string.