fuxkcsdn
V2EX  ›  问与答

API 文档中, Map 数据类型该如何描述?

  •  
  •   fuxkcsdn · Sep 28, 2017 · 1591 views
    This topic created in 3147 days ago, the information mentioned may be changed or developed.

    对于下面的 json

    {
      "goods": [
        {
          "id": 123,
          "qty": 3
        },
        {
          "id": 321,
          "qty": 4
        }
      ]
    }
    

    如果想转换成如下的结构

    {
      "goods": {
        "123": 3,
        "321": 4
      }
    }
    

    那文档里该如何描述 map.key 呢?

    对于这 2 种数据结构,各位推荐用哪种?

    1 replies    2017-09-28 14:44:38 +08:00
    killpanda
        1
    killpanda  
       Sep 28, 2017
    第一种,静态语言好解析,而且每个 item 其实都表示一个固定的资源
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1285 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 23:43 · PVG 07:43 · LAX 16:43 · JFK 19:43
    ♥ Do have faith in what you're doing.