I\'m trying to write a php script that handles data from a webservice that delivers \"json\" as a string. The problem is the string isn\'t really json; it\'s javascript. Spe
Depends on how complicated your data is :
$output = "{desc:'User defined payload',asc:'whatever'}";
function json_js_php($string){
$string = str_replace("{",'{"',$string);
$string = str_replace(":'",'":"',$string);
$string = str_replace("',",'","',$string);
$string = str_replace("'}",'"}',$string);
return $string;
}
echo json_decode(json_js_php($output))->{'desc'};
returns : User defined payload