<?php
$jsonData = array(
"comments" => "Fresh food",
"container" => false,
"cookedTime" => 2,
"description" => "biryani",
"refridgeration" => true,
"serves" => 2,
"veg" => true
);
json_encode($jsonData);
header("Location:Post.php?json=$jsonData");
?>
Run Code Online (Sandbox Code Playgroud)
这是我的php页面,其中包含json对象.我将这个json对象传递到另一个页面Post.php.
<?php
$jsonData = $_GET['json'];
json_decode($jsonData, TRUE);
echo var_dump($jsonData);
?>
Run Code Online (Sandbox Code Playgroud)
当我进行转储时,结果是C:\ wamp\www\Hack\Post.php:16:字符串'Array'(长度= 5).它正在打印"Array"而不是json对象.我该怎么办?
正如1slock所说,你需要对json进行编码,但也要添加urlencode.
header("Location: Post.php?json=" . urlencode( json_encode($jsonData)) );
| 归档时间: |
|
| 查看次数: |
7257 次 |
| 最近记录: |