【问题标题】:Retrofit swap JSON objects改造交换 JSON 对象
【发布时间】:2020-04-25 19:02:01
【问题描述】:

交换两个对象位置以便将它们的新顺序保存在数据库中的最简单方法是什么? 谢谢。

我的路径是: https://localapi.io/artists?userId=1

我有一个 JSON 对象列表。

[
  {
    "deviceId": "1eb5e6bb-d08b-4f3b-8d71-2b3aab6547c9",
    "name": "MDQ",
    "phone": "7738375513",
    "id": 1,
    "userId": 1
  },
  {
    "deviceId": "2eb5e6bb-d08b-4f3b-8d71-2b3aab6547c9",
    "name": "Prismatix",
    "phone": "2244427841",
    "id": 2,
    "userId": 1
  },
  {
    "deviceId": "3eb5e6bb-d08b-4f3b-8d71-2b3aab6547c9",
    "name": "Anderson Paak",
    "phone": "3246743463",
    "id": 3,
    "userId": 1
  },
  {
    "deviceId": "7eb5e6bb-d08b-4f3b-8d71-2b3aab6547c9",
    "name": "Snarky Puppy",
    "phone": "7738375515",
    "id": 7,
    "userId": 1
  }
]

字段“id”是识别艺术家的字段。

【问题讨论】:

    标签: android json database retrofit


    【解决方案1】:

    例如如果使用 python


    对象是一个名为object的变量


    用它来交换

    object[0],object[1]=object[1],object[0]
    

    【讨论】:

    • 我在 Android 工作室工作。我可以在我的应用程序中交换它,但我也想在后端进行永久性更改。
    • 你可以在后台添加代码,post route 工作的地方
    猜你喜欢
    • 2021-07-03
    • 2017-12-29
    • 1970-01-01
    • 2014-10-16
    • 1970-01-01
    • 1970-01-01
    • 2017-09-02
    • 2017-08-02
    • 2016-08-21
    相关资源
    最近更新 更多