這里詳細描述問題
print_r($response);//命令行正常得到數(shù)據(jù)
但是 使用return json($response);//則顯示空白
$request_info = array(
'table_name' => 'x_net_worth',
'index_name' => 'x_net_worth_index',//多元索引名稱
'search_query' => array(
'offset' => 0,//本次查詢的開始位置。
'limit' => 100,//本次查詢需要返回的最大數(shù)量。
'get_total_count' => true,//是否返回匹配的總行數(shù),默認為false,表示不返回。返回匹配的總行數(shù)會影響查詢性能。
'query' => array(
'query_type' => QueryTypeConst::MATCH_ALL_QUERY//設(shè)置查詢類型為QueryTypeConst::TERM_QUERY。
),
'sort' => array(
array(
'field_sort' => array(
'field_name' => 'networth_timestamp',
'order' => SortOrderConst::SORT_ORDER_DESC
)
),
),
'token' => null,
),
'columns_to_get' => array(
'return_type' => ColumnReturnTypeConst::RETURN_ALL,
// 'return_names' => array('networth_fund_code', 'networth_bonus_and_split')
)
);
$response = $otsClient->search($request_info);
print_r($response);//正常得到數(shù)據(jù)
return json($response);//顯示空白
webman'最新版本
windows下
根據(jù)手冊 https://www.php.net/manual/zh/function.json-encode
json數(shù)據(jù)必須是utf8編碼,否則可能返回false
可以試試這個
class BaseController{
protected function debug_printR( $content ) : Response {
$res = "<pre>\n" . print_r( $content , true ) . "<br>\n" . "</pre>\n";
return response( $res , 200 , [
'Content-Type' => 'text/html' ,
] );
}
}