zoukankan      html  css  js  c++  java
  • 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',

                                              ]

                          ]

  • 相关阅读:
    # codeforces 1199 D. Welfare State(思维+dp)
    # codeforces 1245 A. A. Good ol' Numbers Coloring(数学)
    # codeforces 1272 F. Two Bracket Sequences(三维dp + bfs)
    关于MySQL无法启动 ERROR 2003 (HY000)
    PAT 甲级测试题目 -- 1002 A+B for Polynomials
    PAT 甲级测试题目 -- 1001 A+B Format
    Flask 中接收 web 端 JSON 的小例子
    一些工具
    MySql的一些常见问题(Windows 和 Ubuntu 下)
    Python学习笔记
  • 原文地址:https://www.cnblogs.com/musings/p/5530813.html
Copyright © 2011-2022 走看看