Php 如何读取包含\u0000*\u0000\u translate的此类json响应
有人能帮我阅读这种类型的json响应吗Php 如何读取包含\u0000*\u0000\u translate的此类json响应,php,json,Php,Json,有人能帮我阅读这种类型的json响应吗 {"\u0000*\u0000_translate": { "app_text_newcomer":"Newcomer", "app_text_senior":"Senior", "app_text_mostsenior":"Most Senior", "app_text_results":"Result", "app_text_result":"Result", "app_text_agenda":"Agenda", "ap
{"\u0000*\u0000_translate":
{
"app_text_newcomer":"Newcomer",
"app_text_senior":"Senior",
"app_text_mostsenior":"Most Senior",
"app_text_results":"Result",
"app_text_result":"Result",
"app_text_agenda":"Agenda",
"app_text_dbvg":"Dbvg"
},
"0":{}
}
如何获取该值\u0000*\u0000\u translate看起来像JSON,所以使用它来获取PHP对象或关联数组
编辑:刚刚试过,我发现了你的问题。json_decode()无法处理数据中的空值,因此您应该对此提出一个bug
解决方法:将\u0000预处理为某个sentinel值,您可以稍后替换为真正的空值:
如果您只想查看它是什么字符,可以在此处对其进行pase,然后单击“JSON to XML”:
$json = '{"\u0000*\u0000_translate": { "app_text_newcomer":"Newcomer", "app_text_senior":"Senior", "app_text_mostsenior":"Most Senior", "app_text_results":"Result", "app_text_result":"Result", "app_text_agenda":"Agenda", "app_text_dbvg":"Dbvg"}, "0":{}}';
$json = str_replace('\u0000', 'XNULLX', $json);
$arr = json_decode($json, true);
foreach ($arr as $k => $v) {
if (strpos($k, 'XNULLX') !== false) {
unset($arr[$k]);
$k = str_replace('XNULLX', "\0", $k);
$arr[$k] = $v;
}
}
echo var_export($arr, true);