Json数据,转换规则,

时间:2023-03-08 17:26:49

JSON数据转换,规则是遇见json 中的{},则是数组[],遇见name:value,则是'key'=>'value', 但是不带键值的数组如['xxxxxx'],json_encode后仍然是'["xxxxx"]',若带键值,如['y'=>'xxxxxx'],则会转换为{'y':'xxxxxxxx'}这样的形式,完整例子,比如下面的可以相互转换,

{
   datas:[{stuid:"xxx",
      stuNo:"xxx",
      stuName:"xxx",
      completedSize:"xxx",
      uncompletedSize:"xxx"
      },
      {stuid:"xxx",
      stuNo:"xxx",
      stuName:"xxx",
      completedSize:"xxx",
      uncompletedSize:"xxx"
      }
   ],   
   page:{currpage:1,pageNo:"xxx",totals:"xxx"}
}

如果组织数据则是[

'datas'=>[

0=>[

'stuid'=>'xxxxx',

'stuNo'=>'xxxxxxxx',

'stuName'=>'xxxxxxxxxxxxx',

'completedSize=>'xxxxxxxx',

'uncompleteSize'=>'xxxxxxxxxxxx',

],

1=>[

'stuid'=>'xxxxx',

'stuNo'=>'xxxxxxxx',

'stuName'=>'xxxxxxxxxxxxx',

'completedSize=>'xxxxxxxx',

'uncompleteSize'=>'xxxxxxxxxxxx',

]

]

'page'=>[

currentPage=>'1',

pageNo=>'xxxx',

totals=>'x',

]

]