如何在Android应用程序中格式化Json大数据?

问题描述 投票:0回答:1

我有来自服务器的JSON大数据,我必须对其进行格式化并使其成为相应的应用程序。

我不知道该怎么办

enter image description here

这是我的JSON响应:

[
{
    "PatientID": 61270,
    "ItemId": 113883,
    "InvoiceID": 199223,
    "ReceiptId": null,
    "PatientAdmissionId": null,
    "NurseStationId": null,
    "ServiceListPrice": 800.00,
    "ServiceActualPrice": 800.00,
    "ServiceQuantity": 1,
    "ServiceDate": "/Date(1573464484000)/",
    "ReferralPaidDate": null,
    "ModifiedDate": null,
    "CheckoutTime": null,
    "ServiceProviderId": 40576,
    "DoctorId": 40576,
    "DoctorName": "Md. Shahed Ashraf",
    "ReturnQantity": null,
    "ReturnPrice": null,
    "ReturnPaid": 0.00,
    "ReferrerPaidUserId": null,
    "ReferrerPaidUser": null,
    "Discount": 0.00,
    "DiscountAfterInvoice": false,
    "IsBothSideDiscount": true,
    "DiscountPercentage": 0,
    "Refund": false,
    "RefundApprovedBy": null,
    "RefundStatus": 101,
    "RefundApproval": false,
    "IsReturn": false,
    "RefundNote": "Test2",
    "Billed": true,
    "ReferralFee": 320.00,
    "ReferralFeePaid": false,
    "ReferralFeeActual": 320.00,
    "DeliveryDate": "/Date(1573495200000)/",
    "DeliveryTime": null,
    "ReportFormatName": null,
    "LabStatusId": 1,
    "InventoryId": null,
    "ModifiedBy": 30253,
    "PrescriptionItemId": null,
    "Item": {
        "Name": "RA",
        "GenericName": null,
        "Code": "0184",
        "CompanyName": null,
        "ItemTypeId": 32,
        "MedicalTypeId": 62,
        "ItemSpecimentId": 15,
        "ItemCategoryId": 50440,
        "ItemSubCategoryId": null,
        "ItemGroupCategoryId": null,
        "ItemSubGroupCategoryId": null,
        "SupplierOrVendorId": null,
        "Strength": null,
        "Formulation": null,
        "IsAntibiotic": false,
        "MedicineTypeId": null,
        "IsSurgeryItem": false,
        "MeasurementUnitId": null,
        "SalePrice": 800.00,
        "BuyPrice": 0,
        "ServiceProviderId": null,
        "ReferralAllowed": true,
        "Description": null,
        "DefaultReferrarFee": 320.00,
        "LabReportGroupId": 73,
        "NurseStationId": null,
        "NurseStation": null,
        "TaskTypeId": 101,
        "TaskType": null,
        "LabCountDay": 1,
        "IsLabReportItem": false,
        "CreatedDate": null,
        "BedOccupancies": [],
        "Inventories": [],
        "Item_ItemGroup": [],
        "ItemDefaults": [],
        "ItemReorders": [],
        "InitialSetupItems": [],
        "ServiceProviderSurgeryPrices": [],
        "ItemType": null,
        "ItemSpeciment": {
            "Name": "Blood",
            "MedicalTypeId": 62,
            "Items": [],
            "MedicalType": null,
            "TenantId": 16,
            "Tenant": null,
            "Id": 15,
            "Active": true,
            "UserId": 30254,
            "HasErrors": false,
            "ErrorCount": 0,
            "NoErrors": true
        },
        "ItemCategory": {
            "Name": "Serology",
            "MedicalTypeId": 62,
            "ReferralCommission": 40,
            "Items": [],
            "ItemSubCategories": [],
            "MedicalType": null,
            "TenantId": 16,
            "Tenant": null,
            "Id": 50440,
            "Active": true,
            "UserId": 30254,
            "HasErrors": false,
            "ErrorCount": 0,
            "NoErrors": true
        },
        "ItemSubCategory": null,
        "ItemGroupCategory": null,
        "ItemSubGroupCategory": null,
        "MedicineType": null,
        "MeasurementUnit": null,
        "MedicalType": null,
        "ServiceProvider": null,
        "LabReportGroup": {
            "Name": "Serology",
            "Items": [],
            "BranchId": 0,
            "Branch": null,
            "TenantId": 16,
            "Tenant": null,
            "Id": 73,
            "Active": true,
            "UserId": 30254,
            "HasErrors": false,
            "ErrorCount": 0,
            "NoErrors": true
        },
        "SupplierOrVendor": null,
        "PatientServices": [],
        "ReceiptPayments": [],
        "InventoryItem": [],
        "ItemRequisition": [],
        "ExpiryDate": "N/A",
        "Inventory": null,
        "Quantity": 0,
        "PrescriptionItemId": null,
        "BranchId": 0,
        "Branch": null,
        "TenantId": 16,
        "Tenant": null,
        "Id": 113883,
        "Active": true,
        "UserId": 30254,
        "HasErrors": false,
        "ErrorCount": 0,
        "NoErrors": true
    },
    "Inventory": null,
    "User": null,
    "Patient": {
        "OldId": null,
        "FirstName": "MD",
        "LastName": "Pannu",
        "PhoneNumber": "01728621378",
        "GenderId": 1,
        "BloodGroup": null,
        "BloodGroupId": null,
        "FatherName": null,
        "DOB": "/Date(221335200000)/",
        "NationalId": "",
        "Occupation": null,
        "Street": "Elephentroad",
        "City": "Dhaka",
        "Zip": "",
        "Country": "BD",
        "Email": "",
        "Photo": "bfa0f55f-f016-490c-9191-cdc7568392a0.jpg",
        "EmergencyNumber": "",
        "EmergencyContactName": "",
        "EmergencyContactRelation": "",
        "CreatedDate": "/Date(1546768262430)/",
        "Gender": {
            "Name": "Male",
            "Code": 101,
            "TypeName": "Male",
            "User": null,
            "BloodDonors": [],
            "Id": 1,
            "Active": true,
            "UserId": 2,
            "HasErrors": false,
            "ErrorCount": 0,
            "NoErrors": true
        },
        "Memberships": [],
        "PatientInvoices": [],
        "PatientServices": [],
        "Payments": [],
        "DoctorAppointments": [],
        "TenantId": 16,
        "Tenant": null,
        "Id": 61270,
        "Active": true,
        "UserId": null,
        "HasErrors": false,
        "ErrorCount": 0,
        "NoErrors": true
    },
    "PatientInvoice": null,
    "ServiceProvider": {
        "ContactId": 71088,
        "Title": "Dr.",
        "ServiceProviderTypeId": 56,
        "NurseStationId": null,
        "DepartmentId": 425,
        "Degree": "MBBS (CU), BCS (Health)",
        "Speciality": "",
        "Description": "null",
        "Code": "",
        "AssignedToAllUsers": true,
        "IsInHouse": true,
        "IsReferer": true,
        "Designation": "Asst. Prof.",
        "HasSigningPermission": false,
        "IsSurgeon": false,
        "JoiningDate": null,
        "CreatedDate": null,
        "Contact": {
            "FirstName": "Md. Shahed",
            "LastName": "Ashraf",
            "PhoneNumber": "01711319123",
            "GenderId": 1,
            "Street": "",
            "City": "",
            "Zip": "",
            "Country": "BD",
            "Email": "",
            "Fax": "",
            "WebSite": "null",
            "Photo": "null",
            "IsCompany": null,
            "ServiceProviders": [],
            "ServiceProviderType": 56,
            "Gender": {
                "Name": "Male",
                "Code": 101,
                "TypeName": "Male",
                "User": null,
                "BloodDonors": [],
                "Id": 1,
                "Active": true,
                "UserId": 2,
                "HasErrors": false,
                "ErrorCount": 0,
                "NoErrors": true
            },
            "TenantId": 16,
            "Tenant": null,
            "Id": 71088,
            "Active": true,
            "UserId": 30254,
            "HasErrors": false,
            "ErrorCount": 0,
            "NoErrors": true
        },
        "Department": {
            "Name": "Medicine",
            "ServiceProviders": [],
            "TenantId": 16,
            "Tenant": null,
            "Id": 425,
            "Active": true,
            "UserId": 30253,
            "HasErrors": false,
            "ErrorCount": 0,
            "NoErrors": true
        },
        "Items": [],
        "PatientAdmissions": [],
        "NurseStationInchargeList": [],
        "ServiceProviderType": {
            "Name": "Doctor",
            "ServiceProviders": [],
            "LanguageCode": null,
            "Id": 56,
            "Active": true,
            "UserId": null,
            "HasErrors": false,
            "ErrorCount": 0,
            "NoErrors": true
        },
        "DepartmentName": null,
        "ReferralFee": 0,
        "BranchId": 25,
        "Branch": {
            "Name": "Main",
            "IsMainBranch": false,
            "TenantId": 16,
            "Tenant": {
                "Name": "mobileapp",
                "Url": "mobileapp",
                "Id": 16,
                "Active": true,
                "UserId": 2,
                "HasErrors": false,
                "ErrorCount": 0,
                "NoErrors": true
            },
            "Id": 25,
            "Active": true,
            "UserId": 2,
            "HasErrors": false,
            "ErrorCount": 0,
            "NoErrors": true
        },
        "TenantId": 16,
        "Tenant": null,
        "Id": 40576,
        "Active": true,
        "UserId": null,
        "HasErrors": false,
        "ErrorCount": 0,
        "NoErrors": true
    },
    "PrescriptionItem": null,
    "Doctor": {
        "ContactId": 71088,
        "Title": "Dr.",
        "ServiceProviderTypeId": 56,
        "NurseStationId": null,
        "DepartmentId": 425,
        "Degree": "MBBS (CU), BCS (Health)",
        "Speciality": "",
        "Description": "null",
        "Code": "",
        "AssignedToAllUsers": true,
        "IsInHouse": true,
        "IsReferer": true,
        "Designation": "Asst. Prof.",
        "HasSigningPermission": false,
        "IsSurgeon": false,
        "JoiningDate": null,
        "CreatedDate": null,
        "Contact": {
            "FirstName": "Md. Shahed",
            "LastName": "Ashraf",
            "PhoneNumber": "01711319123",
            "GenderId": 1,
            "Street": "",
            "City": "",
            "Zip": "",
            "Country": "BD",
            "Email": "",
            "Fax": "",
            "WebSite": "null",
            "Photo": "null",
            "IsCompany": null,
            "ServiceProviders": [],
            "ServiceProviderType": 56,
            "Gender": {
                "Name": "Male",
                "Code": 101,
                "TypeName": "Male",
                "User": null,
                "BloodDonors": [],
                "Id": 1,
                "Active": true,
                "UserId": 2,
                "HasErrors": false,
                "ErrorCount": 0,
                "NoErrors": true
            },
            "TenantId": 16,
            "Tenant": null,
            "Id": 71088,
            "Active": true,
            "UserId": 30254,
            "HasErrors": false,
            "ErrorCount": 0,
            "NoErrors": true
        },
        "Department": {
            "Name": "Medicine",
            "ServiceProviders": [],
            "TenantId": 16,
            "Tenant": null,
            "Id": 425,
            "Active": true,
            "UserId": 30253,
            "HasErrors": false,
            "ErrorCount": 0,
            "NoErrors": true
        },
        "Items": [],
        "PatientAdmissions": [],
        "NurseStationInchargeList": [],
        "ServiceProviderType": {
            "Name": "Doctor",
            "ServiceProviders": [],
            "LanguageCode": null,
            "Id": 56,
            "Active": true,
            "UserId": null,
            "HasErrors": false,
            "ErrorCount": 0,
            "NoErrors": true
        },
        "DepartmentName": null,
        "ReferralFee": 0,
        "BranchId": 25,
        "Branch": {
            "Name": "Main",
            "IsMainBranch": false,
            "TenantId": 16,
            "Tenant": {
                "Name": "mobileapp",
                "Url": "mobileapp",
                "Id": 16,
                "Active": true,
                "UserId": 2,
                "HasErrors": false,
                "ErrorCount": 0,
                "NoErrors": true
            },
            "Id": 25,
            "Active": true,
            "UserId": 2,
            "HasErrors": false,
            "ErrorCount": 0,
            "NoErrors": true
        },
        "TenantId": 16,
        "Tenant": null,
        "Id": 40576,
        "Active": true,
        "UserId": null,
        "HasErrors": false,
        "ErrorCount": 0,
        "NoErrors": true
    },
    "NurseStation": null,
    "ReceiptPayment": null,
    "PatientAdmission": null,
    "Isgroup": false,
    "PatientServiceIds": null,
    "GroupItemIds": null,
    "MedicalTypeId": 0,
    "BeforeReturnPrice": 0,
    "ReturnBackupPrice": 0,
    "FullReturnServiceListPrice": 0,
    "BranchId": 25,
    "Branch": null,
    "TenantId": 16,
    "Tenant": null,
    "Id": 218017,
    "Active": true,
    "UserId": 30253,
    "HasErrors": false,
    "ErrorCount": 0,
    "NoErrors": true
  }
]

您可以在图片中看到,我必须对其进行格式化并使其成为相应的应用程序。

现在我该怎么办?

android json rest api bigdata
1个回答
0
投票

检查此

        var jsonObj = jsonArr.optJSONObject(0)
        var firstName = jsonObj.optJSONObject("Patient").optString("FirstName")
        var lastName = jsonObj.optJSONObject("Patient").optString("LastName")
        var itemName=jsonObj.optJSONObject("Item").optString("Name")
        var categoryName=jsonObj.optJSONObject("Item").optJSONObject("ItemCategory").optString("Name")
        var patientID=jsonObj.optString("PatientID")
        var patientName = firstName + lastName
© www.soinside.com 2019 - 2024. All rights reserved.