note 112084 deleted from function.json-decode by salathe

From: Date: Mon, 21 Sep 2020 15:01:49 +0000
Subject: note 112084 deleted from function.json-decode by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215439@lists.php.net to get a copy of this message
Note Submitter: php_net_01_weber at nachvorne de ---- json_decode_nice + keep linebreaks: function json_decode_nice($json, $assoc = TRUE){ $json = str_replace(array("\n","\r"),"\\n",$json); $json = preg_replace('/([{,]+)(\s*)([^"]+?)\s*:/','$1"$3":',$json); $json = preg_replace('/(,)\s*}$/','}',$json); return json_decode($json,$assoc); } by phpdoc at badassawesome dot com, I just changed line 2. If you want to keep the linebreaks just escape the slash.

« previous php.notes (#215439) next »