Sample code:
<?php
$json = "['foo', 'bar']";
var_dump( json_decode($json) );
It works with PHP 5.5.3 but it fails for lower PHP's versions
It works on my machine with PHP 5.5.3 but it fails everywhere else.
I know it is incorrect JSON but my webservice gives me JSON with '
symbols together with "
['foo', "bar", {'test': "crazy "markup""}]
Sandbox
How to parse JSON data with apostrophes in PHP 5.3? Obviously original JSON I want to parse is more complex.
(I can't upgrade my PHP on production server neither get proper JSON from webservice)
Here's an alternative solution to this problem:
This approach is more robust than h2ooooooo's function in two respects:
"
, for which h2o's version seems to go into an infinite loop.Test:
Output: