如果我们在 API 响应中有 JSONobject 和 JSONarray,如何生成 PoJo class?

How to generate PoJo class if we have the JSONobject and JSONarray in the API response?

{
    "CustId": "10705",
    "UserName": "3721",
    "Password": null,
    "AdminPassword": null,
    "CustName": "PB 65 V 3721",
    "CustType": "30",
    "CustKey": "980964ee-2abd-4352-9817-206d7ece8d04",
    "IsSubUser": true,
    "Announcement": "",
    "showIcons": "1111111111",
    "ResponseStatus": {
        "Status": true,
        "ErrorCode": null,
        "StackTrace": null,
        "Message": null,
        "Error": null
    }
}

使用json pojo 在线工具。我最常使用的是这个。这是link

只需 post 您的回复,它就会为您转换 pojo。然后你可以使用 gson 将 json 映射到你的 pojo。

希望这对您有所帮助。

访问here

  1. 将您的 JSON 粘贴到左侧。
  2. 然后 Select 输入 JSON
  3. 注释样式:Gson
  4. getter/setter 点击 preview/save Zip。

完成后,您必须进行一些编辑以维护嵌套 类。