我想创建一个JSON编码使用下面的代码,但它包含完整的JSON作为两个独立的项目第二个JSON实体需要包含在属性中。代码创建两个JSON元素时,应该只是一个
//我们只是想在这里使用简单的php json编码,不需要过于复杂。
public function generate_json($table_data) {
$result=array();
$result[]=$table_data;
if ($table_data) {
$result[]= $this->exporter->get_property_gallery_data(20);
}
return json_encode($result);
}
public function get_table_data() {
$where = $this->get_query_where();
$query = "SELECT * FROM `#__{$this->export_table}` WHERE 1 " . $where;
return wpl_db::select($query, 'loadAssocList');
}
public function get_property_gallery_data($property_id) {
$items_table="wpl_items";
$where = $this->get_query_where();
$query = "SELECT * FROM `#__wpl_items` WHERE 1 " .$where.' and parent_id='.$property_id;
return wpl_db::select($query, 'loadAssocList');
}
如果粘贴下面的JSON成浏览器可以得到一个例子
什么实际效果,什么是预期的结果? – Med
两个json元素,而不是一个组合的json元素是图库中的物品在一个sperate中应该是正确的{} – rogue39nin
请在您的问题中添加精确的JSON,以及精确的JSON你希望... – Random