Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/PhpReports/PhpReports.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,12 @@ public static function load($dir, $skip=array()) {
*/
public static function json_decode($json, $assoc=false) {
//replace single quoted values
$json = preg_replace('/:\s*\'(([^\']|\\\\\')*)\'\s*([},])/e', "':'.json_encode(stripslashes('$1')).'$3'", $json);
$callback = function ($matches) { return ':'.json_encode(stripslashes('$matches[1]')).'$matches[3]'; } ;
$json = preg_replace_callback('/:\s*\'(([^\']|\\\\\')*)\'\s*([},])/', $callback, $json);

//replace single quoted keys
$json = preg_replace('/\'(([^\']|\\\\\')*)\'\s*:/e', "json_encode(stripslashes('$1')).':'", $json);
$callback = function ($matches) { return json_encode(stripslashes('$matches[1]')).':'; } ;
$json = preg_replace_callback('/\'(([^\']|\\\\\')*)\'\s*:/', $callback, $json);

//remove any line breaks in the code
$json = str_replace(array("\n","\r"),"",$json);
Expand Down