StackSN StackSN - 4 months ago 51
JSON Question

Parsing non standard JSON in PHP

This is a non standard

format api :

WebInfo ({
"name": "Google",
"code": 1,
"domain": "",

as the data is not a standard JSON,
can not be resolved directly, what can I do to make it become a valid
format ?


You will have to strip out WebInfo ( and ) which can be done by using str_replace()

Try this: Lets assume your string that has WebInfo({...}) is $str then do this:

$str = str_replace('MusicInfoCallback(', '', $str); 
$str = str_replace(' )', '', $str);
print_r(json_decode($str, true));