SpringBoot JSON problem

The JSON returned by the

query using SpringBoot"s default json, database is like this

[{
    "bg_CycleId": null,
    "bg_BugId": null,
    "bg_Status": "Closed",
    "bg_Responsible": "",
    "bg_Project": null,
    "bg_Subject": null,
    "bg_Summary": "1",
    "bg_Description": "<html><body>1</body></html>",
    "bg_DevComments": null,
    "bg_Reproducible": "Y",
    "bg_Severity": "1-",
    "bg_Priority": "5-Urgent",
    "bg_DetectedBy": null,
    "bg_TestReference": null,
    "bg_CycleReference": null,
    "bg_RunReference": null,
    "bg_StepReference": null,
    "bg_DetectionDate": null,
    "bg_DetectionVersion": null,
    "bg_PlannedClosingVer": null,
    "bg_EstimatedFixTime": null,
    "bg_ActualFixTime": null,
    "bg_ClosingDate": null,
    "bg_ClosingVersion": null,
    "bg_ToMail": null,
    "bg_Attachment": "Y",
    "bg_User01": null,
    "bg_User02": null,
    "bg_User03": null,
    "bg_User04": null,
    "bg_User05": null,
    "bg_User06": null,
    "bg_User07": null,
    "bg_User08": null,
    "bg_User09": null,
    "bg_User10": null,
    "bg_User11": null,
    "bg_User12": null,
    "bg_User13": null,
    "bg_User14": null,
    "bg_User15": null,
    "bg_User16": null,
    "bg_User17": null,
    "bg_User18": null,
    "bg_User19": null,
    "bg_User20": null,
    "bg_User21": null,
    "bg_User22": null,
    "bg_User23": null,
    "bg_User24": null,
    "bg_UserHr01": null,
    "bg_UserHr02": null,
    "bg_UserHr03": null,
    "bg_UserHr04": null,
    "bg_UserHr05": null,
    "bg_UserHr06": null,
    "bg_BugVerStamp": null,
    "bg_HasChange": null,
    "bg_Vts": "2017-08-23 14:11:59",
    "bg_ExtendedReference": null,
    "bg_TaskStatus": null
}, {
    "bg_CycleId": null,
    "bg_BugId": null,
    "bg_Status": "Closed",
    "bg_Responsible": "",
    "bg_Project": null,
    "bg_Subject": null,
    "bg_Summary": "2excel",
    "bg_Description": "<html><body>2excel</body></html>",
    "bg_DevComments": null,
    "bg_Reproducible": "Y",
    "bg_Severity": "1-",
    "bg_Priority": "5-Urgent",
    "bg_DetectedBy": null,
    "bg_TestReference": null,
    "bg_CycleReference": null,
    "bg_RunReference": null,
    "bg_StepReference": null,
    "bg_DetectionDate": null,
    "bg_DetectionVersion": null,
    "bg_PlannedClosingVer": null,
    "bg_EstimatedFixTime": null,
    "bg_ActualFixTime": null,
    "bg_ClosingDate": null,
    "bg_ClosingVersion": null,
    "bg_ToMail": null,
    "bg_Attachment": "Y",
    "bg_User01": null,
    "bg_User02": null,
    "bg_User03": null,
    "bg_User04": null,
    "bg_User05": null,
    "bg_User06": null,
    "bg_User07": null,
    "bg_User08": null,
    "bg_User09": null,
    "bg_User10": null,
    "bg_User11": null,
    "bg_User12": null,
    "bg_User13": null,
    "bg_User14": null,
    "bg_User15": null,
    "bg_User16": null,
    "bg_User17": null,
    "bg_User18": null,
    "bg_User19": null,
    "bg_User20": null,
    "bg_User21": null,
    "bg_User22": null,
    "bg_User23": null,
    "bg_User24": null,
    "bg_UserHr01": null,
    "bg_UserHr02": null,
    "bg_UserHr03": null,
    "bg_UserHr04": null,
    "bg_UserHr05": null,
    "bg_UserHr06": null,
    "bg_BugVerStamp": null,
    "bg_HasChange": null,
    "bg_Vts": "2017-08-23 14:12:01",
    "bg_ExtendedReference": null,
    "bg_TaskStatus": null
}]

while LayUi requires that the JSON format returned is as follows:

{
  "code": 0,
  "msg": "",
  "count": 1000,
  "data": [{
    "id": 10000,
    "username": "user-0",
    "sex": "",
    "city": "-0",
    "sign": "-0",
    "experience": 255,
    "logins": 24,
    "wealth": 82830700,
    "classify": "",
    "score": 57
  }, {
    "id": 10001,
    "username": "user-1",
    "sex": "",
    "city": "-1",
    "sign": "-1",
    "experience": 884,
    "logins": 58,
    "wealth": 64928690,
    "classify": "",
    "score": 27
  }, {
    "id": 10002,
    "username": "user-2",
    "sex": "",
    "city": "-2",
    "sign": "-2",
    "experience": 650,
    "logins": 77,
    "wealth": 6298078,
    "classify": "",
    "score": 31
  }, {
    "id": 10003,
    "username": "user-3",
    "sex": "",
    "city": "-3",
    "sign": "-3",
    "experience": 362,
    "logins": 157,
    "wealth": 37117017,
    "classify": "",
    "score": 68
  }, {
    "id": 10004,
    "username": "user-4",
    "sex": "",
    "city": "-4",
    "sign": "-4",
    "experience": 807,
    "logins": 51,
    "wealth": 76263262,
    "classify": "",
    "score": 6
  }, {
    "id": 10005,
    "username": "user-5",
    "sex": "",
    "city": "-5",
    "sign": "-5",
    "experience": 173,
    "logins": 68,
    "wealth": 60344147,
    "classify": "",
    "score": 87
  }, {
    "id": 10006,
    "username": "user-6",
    "sex": "",
    "city": "-6",
    "sign": "-6",
    "experience": 982,
    "logins": 37,
    "wealth": 57768166,
    "classify": "",
    "score": 34
  }, {
    "id": 10007,
    "username": "user-7",
    "sex": "",
    "city": "-7",
    "sign": "-7",
    "experience": 727,
    "logins": 150,
    "wealth": 82030578,
    "classify": "",
    "score": 28
  }, {
    "id": 10008,
    "username": "user-8",
    "sex": "",
    "city": "-8",
    "sign": "-8",
    "experience": 951,
    "logins": 133,
    "wealth": 16503371,
    "classify": "",
    "score": 14
  }, {
    "id": 10009,
    "username": "user-9",
    "sex": "",
    "city": "-9",
    "sign": "-9",
    "experience": 484,
    "logins": 25,
    "wealth": 86801934,
    "classify": "",
    "score": 75
  }]
}

how to convert to the format officially required by layui? Or do you want to use a third-party JSON package

Mar.23,2021

third party, jackson, professional, support pojo


what you return directly is a list of objects (List < OBJECT >),
UI requires a composite object that contains four properties of code,msg,count,data, and then the data property is a list of objects.
can encapsulate the returned object,
write a POJO, to define four properties, code,msg,count,data,
then the data property is a List < OBJECT >, which is used to put your existing object list,
and then return the pojo to the foreground

Menu