Sojtin Sojtin - 5 months ago 37
JSON Question

How to parse not separated json string?

I want to parse some json response into php array, the problem is nginx push stream module response with not separated json string, is possible to parse this without using regex?

'{"id":1,"channel":"1","text":"Hello World!"}{"id":2,"channel":"1","text":"Hello World!"}{"id":2,"channel":"1","text":{"key_x": "value_x"}}'

$str = '{"id":1,"channel":"1","text":"Hello World!"}{"id":2,"channel":"1","text":"Hello World!"}{"id":2,"channel":"1","text":"Hello World!"}';

$str = str_replace('}{', '},{', $str);
$str = '[' . $str . ']';