首页 > 解决方案 > 带有 Rest API 的 IOS Swift 的正确 Json 结构

问题描述

从需要存储多次出现的信息的 IOS swift 设备获取的正确 JSON 结构是什么。我必须存储一个人的多个地址,其中一个是他居住的当前地址。如果 IOS 应用程序是用 swift 编写的,我应该如何接受当前的占用。我使用“iscurrent”来检查当前和以前的占用情况。另请建议在 get API 中发送此 json 信息的正确方法是什么。我在下面使用post和get。在获取发送当前占用率始终位于顶部。

{
  "items": [
    {
      "address": "string",
      "city": "string",
      "suburb": "string",
      "postcode": "string",
      "moveindate": "string",
      "landlordname": "string",
      "landlordemail": "string",
      "iscurrent": 0,
      "occid": 0
    }
  ]
}

有人建议我保存后发送如下。

{
  "items": 
    "iscurrent" = {
      "address": "string",
      "city": "string",
      "suburb": "string",
      "postcode": "string",
      "moveindate": "string",
      "landlordname": "string",
      "landlordemail": "string",
      "occid": 1
    },
  "previous" = [{
      "address": "string",
      "city": "string",
      "suburb": "string",
      "postcode": "string",
      "moveindate": "string",
      "landlordname": "string",
      "landlordemail": "string",
      "occid": 2
    },{
      "address": "string",
      "city": "string",
      "suburb": "string",
      "postcode": "string",
      "moveindate": "string",
      "landlordname": "string",
      "landlordemail": "string",
      "occid": 3
    },
   ]

} 

标签: jsonrestobject

解决方案


推荐阅读