Sojtin Sojtin - 1 year ago 99
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"}}'

Answer Source
$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 . ']';


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download