我想从数据库目录中读取json
文件,但是出现The Response content must be a string or object implementing __toString(), "boolean" given.
错误。贝娄是我的代码:
$json = file_get_contents('database/query_templates/course.json');
$data = json_decode($json, TRUE);
echo '<pre/>'; print_r($data); exit;
course.json
文件内容:
{
"post_filter" : {
"operator" : [
{
"operator" : [
{
"range" : {
"created_at" : {
"gte" : "log_start_date",
"lte" : "log_end_date",
"format" : "yyyy-MM-dd"
}
}
},
{
"terms" : {
"search_param_user_action.id" : "user_select_array"
}
}
]
},
{
"operator" : [
{
"operator" : [
"conduct_days_multi"
]
},
{
"operator" : [
"dropdowns"
]
}
]
},
{
"query" : {
"multi_match" : {
"query" : "x",
"fields" : [
"resource_search_columns"
],
"operator" : "operator"
}
}
}
]
}
}
感谢任何帮助。
答案 0 :(得分:0)
有时一些php发布不支持get_file_contents()或者这个func返回类型字符串但不仅每次都返回字符串,有时返回布尔值,因为它正在处理字节代码,你可以尝试传统的文件操作方法或者你可以尝试转换为字符串。