Json 反序列化 return 空
Json deserialization return null
我正在尝试反序列化此 json。
实际上,我一直使用 simple html dom
库来获取 Web 内容,所以下一步我要做的是使用 json_decode()
函数。但是当我打印函数返回的值时,我得到 NULL
。这是代码:
<?php
require_once("simplehtmldom_1_5/simple_html_dom.php");
$html = file_get_html('http://it.soccerway.com/a/block_competition_tables?block_id=page_competition_1_block_competition_tables_8&callback_params=%7B%22season_id%22%3A11663%2C%22round_id%22%3A31554%2C%22outgroup%22%3Afalse%7D&action=changeTable¶ms=%7B%22type%22%3A%22competition_league_table%22%7D');
$decoded = json_decode($html,true);
var_dump($decoded);
?>
我的代码有什么问题?也许这不是最好的方法?提示我。
看来你的file_get_html功能没有正常使用,你可以用file_get_contents
获取一个网页的内容
<?php
$html = file_get_contents('http://it.soccerway.com/a/block_competition_tables?block_id=page_competition_1_block_competition_tables_8&callback_params=%7B%22season_id%22%3A11663%2C%22round_id%22%3A31554%2C%22outgroup%22%3Afalse%7D&action=changeTable¶ms=%7B%22type%22%3A%22competition_league_table%22%7D');
$decoded = json_decode($html,true);
var_dump($decoded);
?>
我正在尝试反序列化此 json。
实际上,我一直使用 simple html dom
库来获取 Web 内容,所以下一步我要做的是使用 json_decode()
函数。但是当我打印函数返回的值时,我得到 NULL
。这是代码:
<?php
require_once("simplehtmldom_1_5/simple_html_dom.php");
$html = file_get_html('http://it.soccerway.com/a/block_competition_tables?block_id=page_competition_1_block_competition_tables_8&callback_params=%7B%22season_id%22%3A11663%2C%22round_id%22%3A31554%2C%22outgroup%22%3Afalse%7D&action=changeTable¶ms=%7B%22type%22%3A%22competition_league_table%22%7D');
$decoded = json_decode($html,true);
var_dump($decoded);
?>
我的代码有什么问题?也许这不是最好的方法?提示我。
看来你的file_get_html功能没有正常使用,你可以用file_get_contents
<?php
$html = file_get_contents('http://it.soccerway.com/a/block_competition_tables?block_id=page_competition_1_block_competition_tables_8&callback_params=%7B%22season_id%22%3A11663%2C%22round_id%22%3A31554%2C%22outgroup%22%3Afalse%7D&action=changeTable¶ms=%7B%22type%22%3A%22competition_league_table%22%7D');
$decoded = json_decode($html,true);
var_dump($decoded);
?>