今天用restler写api,put,后者post的数据是json,我要在php里面进行解码工作,在进行逻辑部分的操作

 

 $x="{'showname':'zjTestShowName',
'
note':'zjTestShowNote',
'description':'zjTestShowDescription',
'image':'201201/6521874.jpg',
'userId':'0',
'imageNo':'1',
'score':'8'}";

echo '<br/>=================<br/>';
$m=json_decode($x);
var_dump($m);

php  json_decode

 

这个错误,我就开始想,格式没错啊,在花费了十几分钟之后,我决定求助于php手册,

php  json_decode
 是的,我就是犯了这个常见的错误,

// the name and value must be enclosed in double quotes

我改成下面这样就出来结果了:

 1 $x='{"showname":"zjTestShowName",
 2 "note":"zjTestShowNote",
 3 "description":"zjTestShowDescription",
 4 "image":"201201/6521874.jpg",
 5 "userId":"0",
 6 "imageNo":"1",
 7 "score":"8"}';
 8 
 9 echo '<br/>=================<br/>';
10 $m=json_decode($x);
11 var_dump($m);

php  json_decode
 

相关文章:

  • 2021-12-19
  • 2021-09-23
  • 2022-12-23
  • 2021-07-24
  • 2021-09-06
  • 2021-06-27
  • 2022-03-01
  • 2022-12-23
猜你喜欢
  • 2022-01-08
  • 2022-12-23
  • 2021-08-14
  • 2021-10-11
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
相关资源
相似解决方案