Json数据,转换规则,

Posted coco

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Json数据,转换规则,相关的知识,希望对你有一定的参考价值。

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‘,

                                          ]

                      ]

以上是关于Json数据,转换规则,的主要内容,如果未能解决你的问题,请参考以下文章

JSON学习笔记

JSON的基本格式以及与JavaScript之间的转换

Json

json和excel如何快速互转,用这个工具可以轻松搞定!!

submitform改为json

json对象,如何表示数组