-1
我试图输出大括号从我的数组是这样的:PHP数组大括号而不是方括号
"data":{facebook":{"message"}},
,但我不断收到方括号:
"data":{"facebook":["message"]}
这里是我的代码:
$output["contextOut"] = array(array("name" => "$next-context", "parameters" =>
array("param1" => $param1value, "param2" => $param2value)));
$output["speech"] = $outputtext;
$output["data"] = array("facebook" => array("message"));
$output["displayText"] = $outputtext;
$output["source"] = "index.php";
ob_end_clean();
echo json_encode($output);
,这是我的JSON编码输出:
{"contextOut":[{"name":"buy-context","parameters":{"param1":null,"param2":null}}],"speech":"msg","data":{"facebook":["message"]},"displayText":"msg","source":"index.php"}
如何获得大括号而不是方括号?预先感谢您的帮助。
你所需的输出不是有效的JSON。 –
'{}'用于__object__。 –
请参阅[JSON语法](http://www.json.org/) – RiggsFolly