Delphi XSuperObject парсить JSON

Доброго дня ребята. Я получаю в Memo1.text такой JSON

{
  "result": {
    "request": {
      "id": 5985,
      "recDate": "2021-05-17T18:04:25.468624+04:00",
      "matchPercent": 90,
      "juridicalStatusId": 2,
      "juridicalStatusDesc": null,
      "firstName": "Besarion",
      "lastName": "Barateli",
      "country": null,
      "countryISO": "GE",
      "city": "RUSTAVI",
      "postalCode": "0181",
      "address": "?????????? ?40?/1",
      "personalN": "18001001132",
      "documentN": "G5465",
      "registrationN": "0",
      "amlClientId": 0,
      "clientNumber": "1452",
      "brthDate": "1979-05-13T00:00:00",
      "transactionN": "777",
      "scanningTypeId": 1,
      "scanningType": null,
      "scanningPacketId": 3,
      "scanningPacketName": null,
      "scanningDatabases": null,
      "addingReasonId": 0,
      "addingReason": null,
      "organisationId": 1200,
      "userId": 0,
      "userName": null,
      "userFirstName": null,
      "userLastName": null,
      "statusChangeDate": null,
      "statusChangeUserId": 0,
      "statusChangeUserName": null,
      "status": 5,
      "statusText": null,
      "investigationStartDate": null,
      "matchedBlackListId": 0,
      "matchedWhiteListId": 0,
      "dboforigination": null,
      "commentText": null,
      "commentUserId": 0,
      "commentUserName": null,
      "matchCount": 0,
      "checkInAcuris": true,
      "requestForClient": false,
      "deleteStatus": false,
      "organisationUserId": 7,
      "requestUniqueId": "C6DDAA115C574272BBD15C205B0220C8",
      "channelId": 2
    },
    "comments": [
      {
        "id": 0,
        "commentText": "string",
        "userId": 0,
        "userName": null,
        "recDate": null,
        "requestId": null,
        "deleteStatus": false,
        "organisationUserId": 7
      }
    ],
    "scannigPacketDatabases": [
      {
        "id": 12,
        "name": "Sanction - Current",
        "description": "Any individual or entity that is subject to sanctions by either the\r\n                        European Union, the United Nations, the United States Office of\r\n                        Foreign Assets Control and State Department and Her Majesty’s\r\n                        Treasury in the United Kingdom.",
        "scanningPacketID": 3,
        "deleteStatus": false
      },
      {
        "id": 13,
        "name": "Sanction - Previous",
        "description": "Any individual or entity that has formerly been subject to\r\n                        sanctions by either the European Union, the United Nations,\r\n                        the United States Office of Foreign Assets Control and State\r\n                        Department and Her Majesty’s Treasury in the United Kingdom.",
        "scanningPacketID": 3,
        "deleteStatus": false
      },
      {
        "id": 14,
        "name": "PEP",
        "description": "Any individual that is considered a Politically Exposed Person,\r\n                        from Head of State to Members of Parliament, Members of\r\n                        the Board of State Owned Enterprises or Ambassadors and\r\n                        individuals representing their countries interests abroad.",
        "scanningPacketID": 3,
        "deleteStatus": false
      },
      {
        "id": 15,
        "name": "Financial Regulator",
        "description": "Any individual or entity that has been fined or in some other way\r\n                        subject to action by any financial regulatory body",
        "scanningPacketID": 3,
        "deleteStatus": false
      },
      {
        "id": 16,
        "name": "Law Enforcement",
        "description": "Any individual or entity that has been named in official\r\n                        documentation from Law Enforcement bodies such as the\r\n                        Police or any other agency such as Interpol or the FBI.\r\n                        Also those individuals and entities cited in Court and legal\r\n                        documents of that nature.",
        "scanningPacketID": 3,
        "deleteStatus": false
      },
      {
        "id": 17,
        "name": "Adverse Media",
        "description": "Any individual or entity that has been reported in global\r\n                        newspapers, news sites or other media as being involved in\r\n                        financial crime.",
        "scanningPacketID": 3,
        "deleteStatus": false
      }
    ]
  },
  "error": null,
  "success": true
}

Применяю модуль SuperObject и хочу получить на Edit1.Text значения из “status”: 5, это число (5) Я питаюсь парсит так

procedure TForm1.Button2Click(Sender: TObject);
var
  JSONObject : ISuperObject;
begin
   JSONObject:=TSuperObject.Create;
   JSONObject:= SO(Memo1.Text);
   Edit1.Text:=JSONObject.S['status'];
end;

Вопрос: Где я допускаю ошибку и как получить значения из [‘status’] ?

Так он не в корне лежит, надо что-то типа ['result']['request']['status'] (хз какой синтаксис для такого в SuperObject).

1 лайк

Спасибо, тема можно закрыть :wink:

procedure TForm1.Button2Click(Sender: TObject);
var
  JSONObject : ISuperObject;
begin
  JSONObject:= SO(Memo1.Text);
  Edit1.Text:= IntToStr(JSONObject.O['result'].O['request'].I['status']);
end;