2021年7月

究其原因,是因为php和json语法将当成特殊字符, 所以想要原样表达,不要想着如何脱去(这样容易出错,把原本就是的也脱去了).
相反,应该将每个都替换成\, 这样就能表达他原本的意思. 如下例子

$json = '{"myClass": "app\\class\\test"}';
$re = json_decode($json, true);//结果为null

#将\替换成\\即正常了
$newJson = str_replace('\\', '\\\\', $json);
$re = json_decode($newJson, true);//正确输出

参考:
https://stackoverflow.com/questions/32056940/how-to-deal-with-backslashes-in-json-strings-php

排名编程语言Ratings同比上月
1C11.62%-4.83%
2Java11.17%-3.93%
3Python10.95%+1.86%
4C++8.01%+1.80%
5C#4.83%-0.42%
6Visual Basic4.50%-0.73%
7JavaScript2.71%+0.23%
8PHP2.58%+0.68%
9Assembly language2.40%+1.46%
10SQL1.53%+0.13%
11Classic Visual Basic1.39%+0.73%
12R1.32%-1.08%
13Go1.17%-0.04%
14Fortran1.12%+0.90%
15Groovy1.09%+0.51%
16Swift1.07%-0.37%
17Ruby0.95%+0.14%
18Perl0.90%+0.03%
19MATLAB0.88%+0.05%
20Delphi/Object Pascal0.85%+0.36%