Q:

replace "[ with [ and ]" with ] json

I have a JSON as below:
[{"type":"Point","coordinates":"[-77.03,38.90]"},"properties":{"city":3,"url":"xyz.com"}]

I want to replace "[ with [ and ]" with ]

A:

try this
 $yourJson = [{"type":"Point","coordinates":"[-77.03,38.90]"},"properties":{"city":3,"url":"xyz.com"}];
 $jsonString=preg_replace('/"([^"]+)"\s*:\s*/', '$1:', $yourJson);
    $stringReplace=str_replace('"[', '[', $jsonString);
    $stringReplace=str_replace(']"', ']', $stringReplace);
    echo $stringReplace;

