为什么序列化返回stdClass? (PHP)

时间:2016-11-02 05:01:25

标签: php json

我有一个json但是当我使用serialize()返回stdclass?

$json= [{"lt":"1","lot":["0","1","0"]},{"lt":"2","lot":["0","0","0"]}]

和serialize()之后的这个:

a:2:{i:0;O:8:"stdClass":2:{s:2:"lt";s:1:"1";s:3:"lot";a:3:{i:0;s:1:"0";i:1;s:1:"1";i:2;s:1:"0";}}i:1;O:8:"stdClass":2:{s:2:"lt";s:1:"2";s:3:"lot";a:3:{i:0;s:1:"0";i:1;s:1:"0";i:2;s:1:"0";}}}

我需要这样但我无法解决它:

a:2:{i:0;a:2:{s:2:"lt";s:1:"1";s:3:"lot";a:3:{i:0;s:1:"0";i:1;s:1:"1";i:2;s:1:"0";}}i:1;a:2:{s:2:"lt";s:1:"2";s:3:"lot";a:3:{i:0;s:1:"0";i:1;s:1:"0";i:2;s:1:"0";}}}

1 个答案:

答案 0 :(得分:0)

试试

serialize(json_decode($json, true));