StackSN StackSN - 1 year ago 112
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 ?

Answer Source

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));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download